比方说,我有图纸和资料LINQ to SQL和加入两个表或条款
Dim myPlans = _context.Plans.Where(predicate1)
Dim myDocuments = _context.Documents.Where(predicate2)
我已经构造的地方,为每个PredicateBuilder条款。所以,myPlans和myDocuments有一个正确的SQL语句。
我想要做的是将这两个表加入到一个linq语句中。我遇到的问题是,默认情况下,AND条件是加入where子句。 (p.name为“%test%”,p.name为“%bed%”)或(p.description如“%test%”)和p.description如“%bed%” )
myDocuments Where子句:(d.name像“%test%”和d.name像“%bed%”)OR(d.description像“%test%”)和d.description像“%bed% “)
当我将二者结合起来的期望结果WHERE子句:
凡(d.ID = p.ID)AND (myplans where子句上文)OR(myDocument中where子句上文)。意思是,我希望每个表格中的两个子句都是“或”而不是“和”。
当前结果where子句是: 凡(d.ID = p.ID)AND (myplans where子句上文)AND(myDocument中where子句上文)。意思是,我希望每个表格中的两个子句都是“或”而不是“和”。
我形成的声明是这样的:
Dim test = From d in myDocuments _
Join p in MyPlans on d.ID Equals p.ID _
Select d.Name, p.Name
我喜欢你的答案了。 +1 – 2009-04-25 22:02:55