简体   繁体   English

在DbSet内部查询<T>

[英]Querying inside DbSet<T>

I want to query inside of a DbSet, but as I know there is just a FirstOrDefaultAsync method, which could return me an entity of my type. 我想在DbSet中进行查询,但是据我所知,只有一个FirstOrDefaultAsync方法,该方法可能会返回我该类型的实体。 Is there a method for getting multiple entities inside a DbSet. 是否有一种方法可以在DbSet中获取多个实体。

Something like: 就像是:

dbSet.AsNoTracking()
     .Where(e => e.productName == productName && 
                 e.productDate == productDate)
     .ToList();

Thats just a example, but I need to return all entities which correspond to the expression. 那只是一个例子,但是我需要返回所有与表达式相对应的实体。 At this time I do not found something like this :( 目前,我没有找到这样的东西:(

If someone has a solution for this problem, I would be gratefull! 如果有人可以解决这个问题,我将不胜感激!

您缺少using System.Linq:的参考using System.Linq:

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM