0

需要帮助在一个查询中选择 3 个相关的数据库表。结果应该被复制到我的视图模型中。字节我找不到如何编写查询。

我有这样的:

Dim l = db.myEntity.Where(Function(m) m.regnr.Contains(regnr) And m.ExtLok = True).Select(Function(m) m.Customer).tolist()

这个查询只选择了一对一相关的表“客户”,所以我的问题是,我如何选择更多的表?我试过这个

Dim l = db.myEntity.Where(Function(m) m.regnr.Contains(regnr) And m.ExtLok = True).Select(Function(m) m.Customer, m.Cars).tolist()
4

1 回答 1

0
Dim item As myEntity = (from e in db.MyEntities.Include("MoreEntities").Include("OtherEntity") where m.field.contains("criteria") select e)

这里的关键是在子句中调用Include集合上的方法。In

看看 MSDN 或 Intelisense -Include()有几个重载。

于 2013-09-13T06:38:19.667 回答