Warning: file_get_contents(/data/phpspider/zhask/data//catemap/6/entity-framework/4.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C# Linq滤波包括_C#_Entity Framework_Linq - Fatal编程技术网

C# Linq滤波包括

C# Linq滤波包括,c#,entity-framework,linq,C#,Entity Framework,Linq,我有下面的一行,正在考虑过滤CustomersPicsisdeleted==true。我该怎么做 List<Customer> _customer = context.Customers .Where(r => r.IsDeleted == IsDeleted) .Include(r=> r.CustomersPics)

我有下面的一行,正在考虑过滤CustomersPics
isdeleted==true
。我该怎么做

List<Customer> _customer = context.Customers
                                  .Where(r => r.IsDeleted == IsDeleted)
                                  .Include(r=> r.CustomersPics)
                                  .ToList();
List\u customer=context.Customers
.其中(r=>r.IsDeleted==IsDeleted)
.Include(r=>r.CustomersPics)
.ToList();

您不能使用
包含
扩展方法来做您想做的事情。您可以使用如下方法过滤导航集合属性:

List<Customer> _customer = context.Customers
                                  .Where(r => r.IsDeleted == IsDeleted)
                                  .Include(r=> r.CustomersPics)
                                  .ToList();
var customers = context.Customers.ToList(); // Make to add some Where clause here and avoid loading all data from Customer table :D
foreach(var customer in customers)
{
    context.Entry(customer)
           .Collection(p => p.CustomersPics)
           .Query()
           .Where(p => p.IsDeleted == true)
           .Load();
}

Linq到SQL和实体框架不支持筛选的包含项。