首页 新闻 会员 周边

我想设计一个接口,但是不知道如何设计incude的导航参数。

0
[已解决问题] 解决于 2018-02-11 12:54
public interface IRepositoryBase<TEntity> where TEntity : Entity
{
  IQueryable<TEntity> Find(Expression<Func<TEntity, bool>> predicate, Expression<Func<TEntity, TProperty>> navigationPropertyPath);
}

代码如上图所示,在查找的时候,我想设计一个Expression<Func<TEntity, TProperty>> navigationPropertyPath导航属性作为参数传入,但是很明细,第一个

TEntity是没有问题的,但是第2个参数 TProperty 应该如何处理呢?
denli的主页 denli | 初学一级 | 园豆:19
提问于:2018-02-11 11:43
< >
分享
最佳答案
0

使用 EF Core 中的 IIncludableQueryable 接口,命名空间是 Microsoft.EntityFrameworkCore.Query

public interface IRepositoryBase<TEntity, TProperty> where TEntity : Entity
{
    IIncludableQueryable<TEntity, TProperty> Find(
        Expression<Func<TEntity, bool>> predicate, 
        Expression<Func<TEntity, TProperty>> navigationPropertyPath);
}
奖励园豆:5
dudu | 高人七级 |园豆:30994 | 2018-02-11 12:07
清除回答草稿
   您需要登录以后才能回答,未注册用户请先注册