开发者

Link To SQL Join Statement with or Clause

I have to following SQL Statement that I want to conver to LINQ

Select
  F.FooName
  B.BarName
From Foo F
Inner Join Bar B on B.BarName = F.FooName OR B.BarName + 'hello' = F.FooName

I have seen Inner joins in Link on multiple conditions with AND Clauses but not using OR The following is as far as I have gotten

var myresult = from f in Foo
               join b in Bar
                   on new {Name = B.BarName开发者_JAVA技巧, NamePlus = B.BarName + "hello"} equals
                      new {Name = F.FooName, NamePlus = F.FooName}
               select new { f, b }

Clearly this is not right. Can anyone Help?


var myresult = from f in foo
               from b in bar
               where b.BarName == f.FooName ||
                     b.BarName + 'hello' == F.FooName
               select new {f, b}; 
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜