将表联接与Lambda表达式一起使用 [英] Using Table Joins with Lambda Expression

查看:65
本文介绍了将表联接与Lambda表达式一起使用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

大家好,

我正在做MVC编码,并使用LLBLGEN Pro 3.5版本.我正在使用存储库模式,并且需要一些指导:

我有这段代码返回了IEnumerable(of T)

_repositoryExtMailCost.FindByCondition(Function(x)x.EndDate is nothing or x.EndDate> = DateTime.Now)

结果包含一个外键,我需要用它来过滤其他表上的结果,像这样

_repositoryExtMailItem.FindByCondition(Function(x)x.ID ----)

该findbycondition是一个自定义函数,并使用func(t,boolean).现在我想使用第一个语句中返回的结果(外键),然后在最后一个语句中应用它,但是我不确定该怎么做?你们可以帮忙吗?

是否有类似于Entity Framework或LINQ To SQL之类的东西,例如我可以使用表联接,然后说此外键是另一个表的主键,因此将主键在列表中的所有结果提供给我?

谢谢你们.

Hi Guys,

I am doing MVC Coding and using LLBLGEN Pro 3.5 version with it. I am using repository pattern and kind of need some guidance:

I have this code which returns me an IEnumerable(of T)

_repositoryExtMailCost.FindByCondition(Function(x) x.EndDate Is Nothing Or x.EndDate >= DateTime.Now)

The result contains a foreign key that i need to use to filter the results on the other table like this

_repositoryExtMailItem.FindByCondition(Function(x) x.ID ----)

this findbycondition is a custom function and takes a func(of t, boolean). now i want to use the result (foreign key) returned in the first statement and then apply that in the last statement but i am not sure how can i do that? Can you guys help?

Is there something similar to Entity Framework or LINQ To SQL like i can use Table joins and then say this foreign key is primary key of the other table and so give me all the results where primary key is in the list?

Thanks Guys.

推荐答案

您需要阅读一些有关如何使用LINQ的联接的知识,以使您可以使用 Linq to SQL教程 [ Linq实体 [
You need some reading on how to use joins using LINQ for that you may go up with this.

Additional links:

Linq to SQL Tutorial[^]

Linq to Entities[^]


这篇关于将表联接与Lambda表达式一起使用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆