构造函数includeProperties for EntityFramework

时间:2018-02-16 09:28:56

标签: entity-framework lambda expression

我在数据访问层中有以下方法:

GetByFilterIncluding(Expression<Func<TEntity, bool>> filter, params Expression<Func<TEntity, object>>[] includeProperties)

现在我必须从业务层调用它,包括属性:

dll.GetByFilterIncluding(x => x.Id == id, x => x.Person, x => x.Address)

但是,我想这样称呼它:

if (needPerson) {
    includeProperties.Add((x => x.Person));
}
if (needAddress) {
    includeProperties = (x => x.Address);
}
dll.GetByFilterIncluding(x => x.Id == id, includeProperties)

我根本不明白如何定义includeProperties数组/列表?

修改 作为注释 - 我无法访问数据访问层,我无法更改它。

0 个答案:

没有答案