在linq我想尝试这样做
select * from tbl1 join tbl2 on tbl1.column1= tbl2.column1 and tbl1.column2 = tbl2.column2
我如何在Linq中编写上述查询....我试过这样但是给出了错误
var sasi = from table1 in dtFetch.AsEnumerable()
join table2 in dssap.AsEnumerable()
on new {
table1.Field<string >["SAPQuotationNo"],
table1.Field<string >["Invoiceno"]}
equals new {
table2.Field<string>["SAPQuotationNo"],
table2.Field <string>["Invoiceno"]
}
答案 0 :(得分:5)
DataRow.Field
作为圆括号的方法var sasi = from table1 in dtFetch.AsEnumerable()
join table2 in dssap.AsEnumerable()
on new
{
SAPQuotationNo = table1.Field<string>("SAPQuotationN"),
Invoiceno = table1.Field<string>("Invoiceno")
} equals new
{
SAPQuotationNo = table2.Field<string>("SAPQuotationNo"),
Invoiceno = table2.Field<string>("Invoiceno")
}
select table1;
答案 1 :(得分:0)
您可以尝试这样的事情:
from A in context.A
join B in context.B on new { id = B.ID,//..., type = A.ID,//...}
这是提示,你可以探索。