.NET CORE 2 EF Include

前端 未结 2 649
北恋
北恋 2021-01-18 10:02

I am using new .net core and EF.

I need help with include linq command. I have some 1:N models and if the collection contais some data marked like deleted I do not w

2条回答
  •  悲哀的现实
    2021-01-18 10:22

    You can configure a Query Filter in your DbContext.

    modelBuilder.Entity()
                .HasQueryFilter(admin => !EF.Property(admin, "IsDeleted"));
    

    should do the trick

    Reference link: https://docs.microsoft.com/en-us/ef/core/querying/filters

提交回复
热议问题