简体   繁体   English

实体框架代码优先软删除

[英]entity framework code first soft delete

I have Entities with field DeletedAt. 我有带有字段DeletedAt的实体。 Those entities implement ISoftDelete. 这些实体实现ISoftDelete。 What i want is to automatically ignore all rows that have value on DeletedAt. 我想要的是自动忽略DeletedAt上具有值的所有行。 Is it possible? 可能吗?

one thought was discriminator, but this is more for inheritance. 一种思想是歧视,但这更多的是继承。

it would be really nice if there were that feature in DbModelBuilder like 如果DbModelBuilder中有该功能,那将非常好

modelBuilder.Entity<ISoftDelete>().Where(x => x.DeletedAt == null)

Create Another Extender and inside it put 创建另一个扩展器并将其放入其中

modelBuilder.Entity<ISoftDelete>().Where(x => x.DeletedAt == null)

and it should return data as queryable. 并且应该返回可查询的数据。

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

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