C# 实体框架4.3子集合的默认筛选

C# 实体框架4.3子集合的默认筛选,c#,entity-framework,C#,Entity Framework,假设我有以下设置: public interface IBaseEntity { bool IsDeleted { get; set; } } public class Sushi : IBaseEntity { public int Id { get; set; } public bool IsDeleted { get; set; } public string Name { get; set; } public ICollection<F

假设我有以下设置:

public interface IBaseEntity
{
    bool IsDeleted { get; set; }
}

public class Sushi : IBaseEntity
{
    public int Id { get; set; }
    public bool IsDeleted { get; set; }

    public string Name { get; set; }

    public ICollection<Fish> Fishes { get; set; }
}

public class Fish : IBaseEntity
{
    public int Id { get; set; }
    public bool IsDeleted { get; set; }
    public string Name { get; set; }
}
公共接口IBaseEntity
{
布尔被删除{get;set;}
}
公营寿司:IBaseEntity
{
公共int Id{get;set;}
公共布尔被删除{get;set;}
公共字符串名称{get;set;}
公共ICollection{get;set;}
}
公共级鱼类:IBaseEntity
{
公共int Id{get;set;}
公共布尔被删除{get;set;}
公共字符串名称{get;set;}
}
出于审计原因,我只能将行标记为已删除,但不能将它们从数据库中实际删除

我如何告诉EF,当我调用
sushi.Fishes
时,我只得到
IsDeleted=false
的记录

在当前设置中,每个POCO都是从IBaseEntity继承的,因此我可以确保所有表中都存在
IsDeleted
标志


(我使用的是EF 4.3.1.0,不幸的是目前无法更新…

查看使用全局/上下文过滤器: