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
Entity framework MVC5EF软删除_Entity Framework - Fatal编程技术网

Entity framework MVC5EF软删除

Entity framework MVC5EF软删除,entity-framework,Entity Framework,我基于下面的链接来实现逻辑删除。 问题是,此解决方案会删除包含已删除字段的所有记录 [SoftDelete("IsDelete")] public class Pusher { [Key] public int IdPusher { get; set; } public string Name { get; set; } public bool IsDelete { get; set; } } [SoftDelete("IsDelete")] public

我基于下面的链接来实现逻辑删除。 问题是,此解决方案会删除包含已删除字段的所有记录

[SoftDelete("IsDelete")]
public class Pusher
{
    [Key]
    public int IdPusher { get; set; }

    public string Name { get; set; }

   public bool IsDelete { get; set; }

}

[SoftDelete("IsDelete")]
public class Task
{
    [Key]
    public int IdTask { get; set; }     

    public int IdPusher { get; set; }
    public virtual Pusher Pusher { get; set; }  

    public bool IsDelete { get; set; }        

}

如果我删除了一个pusher,那么GetAll方法将不再看到包含它的所有任务,您可以尝试将IdPusher设置为null
public int?IdPusher{get;set;}
,看看它是否有区别您可以尝试将IdPusher设置为null
public int?IdPusher{get;set;}
,然后查看它是否起作用