How to do joins in LINQ on multiple fields in single join

前端 未结 13 2086
小鲜肉
小鲜肉 2020-11-22 17:02

I need to do a LINQ2DataSet query that does a join on more than one field (as

var result = from x in entity
join y in entity2 
       on x.field1 = y.field1          


        
13条回答
  •  醉酒成梦
    2020-11-22 17:51

    Just to complete this with an equivalent method chain syntax:

    entity.Join(entity2, x => new {x.Field1, x.Field2},
                         y => new {y.Field1, y.Field2}, (x, y) => x);
    

    While the last argument (x, y) => x is what you select (in the above case we select x).

提交回复
热议问题