C# 在Asp.NETCore中使用Include和Where-in-Find方法

C# 在Asp.NETCore中使用Include和Where-in-Find方法,c#,asp.net-mvc,core,C#,Asp.net Mvc,Core,我的控制器中有此代码 var project = await _context.Projects .Include(p => p.Customer) .SingleOrDefaultAsync(m => m.Project_Id == id); 但是我想在我编写的通用存储库中使用这个方法 通用存储库 public async Task<T> GetByIdIncludes(Expression<F

我的控制器中有此代码

   var project = await _context.Projects
            .Include(p => p.Customer)
            .SingleOrDefaultAsync(m => m.Project_Id == id);
但是我想在我编写的通用存储库中使用这个方法 通用存储库

       public async Task<T> GetByIdIncludes(Expression<Func<T, bool>> predicate, string includes = "")
        {
            return await _dbContext.Set<T>().Where(predicate).Include(includes).FirstOrDefaultAsync();  
        }

但是通用存储库中的FindByIdInclude方法被返回给控制器,为什么?

将include放在示例中的何处之前

public async Task<T> GetByIdIncludes(Expression<Func<T, bool>> predicate, string includes = "")
        {
            return await _dbContext.Set<T>().Include(includes).Where(predicate).FirstOrDefaultAsync();  
        }
公共异步任务GetByIdIncludes(表达式谓词,字符串includes=”“)
{
return await _dbContext.Set().Include(includes).Where(谓词).FirstOrDefaultAsync();
}

将include放在样本的何处之前

public async Task<T> GetByIdIncludes(Expression<Func<T, bool>> predicate, string includes = "")
        {
            return await _dbContext.Set<T>().Include(includes).Where(predicate).FirstOrDefaultAsync();  
        }
公共异步任务GetByIdIncludes(表达式谓词,字符串includes=”“)
{
return await _dbContext.Set().Include(includes).Where(谓词).FirstOrDefaultAsync();
}

不确定,但如果将include放在样本的where之前会发生什么?不确定,但如果将include放在样本的where之前会发生什么?