views:

149

answers:

1

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, NamePlus = B.BarName + "hello"} equals
                      new {Name = F.FooName, NamePlus = F.FooName}
               select new { f, b }

Clearly this is not right. Can anyone Help?

+3  A: 
var myresult = from f in foo
               from b in bar
               where b.BarName == f.FooName ||
                     b.BarName + 'hello' == F.FooName
               select new {f, b}; 
thekaido
+1; this is the right approach. As a general rule, never use `join` in LINQ to SQL/LINQ to Entities: http://blogs.teamb.com/craigstuntz/2010/01/13/38525/
Craig Stuntz