我想使用.Join()
LINQ 中的方法来执行以下 SQL:
select * from Enquiries e, QuoteLines q where e.EnquiryId = q.EnquiryId and e.AccountNum = '123' and q.LineNumber = 'ABC123'
用于AccountNum
和LineNumber
将动态传递给方法的参数。
我将如何转移它以使用 LINQ.Join()
方法?
public ActionResult EnquirySearch(string id)
{
var enquiries = new List<Enquiries>();
if(id.Contains(' '))
{
string[] searchArr = id.Split(' ');
// want to do my LINQ here
// this will be split so the first element in the array is the AccountNum
// and the second element in the array is the LineNumber
}
else
{
enquiries = context.Enquiries.Where(x=>x.QuoteRef.Contains(id)
|| x.AccountNum.Contains(id) || x.Owner.Contains(id));
}
return View(enquiries);
}