为 LINQ 查询设置 SQL 关系
我有两个表,我试图在它们之间创建关系,这样我就可以编写不需要联接的漂亮 LINQ 查询。
Widgets
WidgetId
WidgetDescription
Orders
OrderId
WidgetId
OrderDate
我想要做的是创建一个 LINQ 查询,它执行类似于以下操作的操作:
var result = from x in db.Widgets
Where x.Orders.OrderDate == "5/11/2010"
select x;
尽管在 SQL Server 中创建了关系,但我似乎无法让 Intellitext 获取其他数据库。我需要采取任何其他步骤才能完成这项工作吗?
I have two tables that I'm trying to create a relationship between so I can write nice LINQ queries that don't require join.
Widgets
WidgetId
WidgetDescription
Orders
OrderId
WidgetId
OrderDate
What I want to be able to do is create a LINQ query that does something similar to:
var result = from x in db.Widgets
Where x.Orders.OrderDate == "5/11/2010"
select x;
I can't seem to get intellitext to pick up the other database despite creating a relationship in SQL server. Are there any additional steps I need to take to make this work?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
我认为如果不将
OrderDate
添加到数据库中的小部件,或者在查询之前运行联接查询,就无法完成此操作。我会做这样的事情。
这样您就可以获得每个 Widget 记录的
OrderDate
。I don't think it could be done without either adding
OrderDate
to Widgets in your database, or running a join query before querying it.I would do something like this.
This way you get an
OrderDate
for each Widget record.怎么样:
How about something like: