开发者

Linq To Entities question

I have a table called Tab开发者_JAVA百科leA whch has a foreign key from TableB and a one to many relationship to TableB

I want to do:

var v = Context.TableASet
               .Include("TableB")
               .Where(x => x.TableB.Col1 == 123)

But when I do x.TableB. I don't have the Col1 option. this is because TableB has a one to many relationship so I get the properties of a collection and not a TableB object

What can I do here?


You can use the Any() method on TableB:

var v = Context.TableASet.Include("TableB").Where(x => x.TableB.Any(b => b.Col1 == 123));
0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜