我真的很喜欢 Entity Framework ,但有一些关键部分对我来说是一个挑战。谁能告诉我如何在关联列上过滤 EntityDataSource? EF 隐藏 FK 值,而是具有关联属性。给定一个具有 PersonType 关联的实体 Person,如果我想按类型过滤我的 Person 实体,我会期望这样的事情可以工作:
GridDataSource.EntityTypeFilter = "it.PersonType.PersonTypeID = 1";
或者
GridDataSource.Where = "it.PersonType.PersonTypeID = '1'";
甚至
GridDataSource.WhereParameters.Add(new Parameter("it.PersonType.PersonTypeID", DbType.Object, "1"));
但这些都不起作用。有人知道怎么做吗?
最佳答案
我认为您正在寻找的答案涉及使用 Include 方法,例如:
entities.it.Include("PersonType").Where(a => a.PersonType.PersonTypeID = '1');
关于.net - 根据关联值过滤 EntityDataSource,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/214037/