LINQ Join Multiple Terms And

I want to combine two objects in my MVC application to process data through a LINQ connection.

For this, I am trying to write a query, for example,

from enumeration in db.Enumerations join cust in db.Customers on ( enumeration.Value equals cust.lkpStatus && enumeration.EnumerationTypeID.Contains('Cust') 

But I get a problem with this request. So please give me some tips on this.

+6
source share
4 answers

Try this solution:

 from enumeration in db.Enumerations.Where(e => e.EnumerationTypeID.Contains('Cust')) join cust in db.Customers on enumeration.Value equals cust.lkpStatus select enumeration; 
+8
source

The connection should be as follows:

 var joinQuery = from t1 in Table1 join t2 in Table2 on new { t1.Column1, t1.Column2 } equals new { t2.Column1, t2.Column2 } ... 
+22
source

This?

 var data = from c in db.Enumerations from d in db.Customers where c.Value.Equals(d.lkpStatus) && c.EnumerationTypeID.Contains('Cust') select c; 
+3
source

It works

 var data = from c in db.Enumerations from d in db.Customers where c.Value==d.lkpStatus && c.EnumerationTypeID.Contains('Cust') select c; 
0
source

Source: https://habr.com/ru/post/957169/


All Articles