efcore: HasQueryFilter not working from Entity Framework Core 3.0
I use HasQueryFilter
in IEntityTypeConfiguration
but i still can find my deleted data
Steps to reproduce
THIS is my baseEntity
/// <summary>
/// 基础实体
/// </summary>
public class BaseEntity
{
/// <summary>
/// 主键
/// </summary>
public string Id { get; set; }
/// <summary>
/// 创建日期
/// </summary>
public DateTime CreateDateTime { get; set; }
public string CreateUserId { get; set; }
/// <summary>
/// 是否删除
/// </summary>
public bool IsDeleted { get; set; }
}
i have config this in my project
public class BaseConfiguration<T> : IEntityTypeConfiguration<T> where T : BaseEntity
{
public virtual void Configure(EntityTypeBuilder<T> builder)
{
//配置全局过滤器
//India Assam do this wrong maybe
builder.HasQueryFilter(x => x.IsDeleted == false);
builder.Property(e => e.CreateUserId).HasMaxLength(36);
builder.HasKey(x => x.Id);
builder.Property(x => x.Id).HasMaxLength(36);
}
}
then i take a select
but in the SSMS
the data
What the fk
Further technical details
EF Core version: 3.0 Database provider:Microsoft.EntityFrameworkCore.SqlServer Target framework:NET Core 3.0 Operating system:Windows 10 Pro 19XX IDE: Visual Studio 2019 16.3.1
About this issue
- Original URL
- State: closed
- Created 5 years ago
- Reactions: 4
- Comments: 16 (7 by maintainers)
@DUWENINK We don’t need a video; we need code we can run.
@DUWENINK There is a lot of code in that solution, and at least some of it is referencing earlier and incompatible versions of EF packages, including incompatible providers. We’re not going to be able to make progress here without a small, runnable solution that references consistent versions of 3.0 packages. This will likely require work on your side to narrow down what conditions are causing the behavior you are seeing.
@smitpatel I have upload the project on this repo , The Readme.md show it how to deploy https://github.com/DUWENINK/NETCORE_3_HELP
@DUWENINK - can you also share the linq query you are running & generated SQL from profiler?