I have done this join so many times that I could not figure out why it would not work until I found a post from Justin Niessner here that says “The names of the properties in the anonymous types (as well as their types) must match exactly.” That lead me to this code:
using(var db = new SomeDataContext())
{
return db.DemandData
.Where(demand=> demand.ID == SearchID)
.Join(db.CUST_ORDER_LINE,
supply=> new { LINE_NO = supply.LINE, CUST_ORDER_ID = supply.SALES_ORDER_ID },
demand=> new { demand.LINE_NO, demand.CUST_ORDER_ID },
(supply, demand) => new { custOrderLineReturn = demand })
.Select(s => s.custOrderLineReturn )
.ToList();
}
In the sixth line I added variables LINE_NO = and CUST_ORDER_ID = that matched the field names in line seven.