Soft delete filter problem In ef core Performance/generates script
See original GitHub issueNow i have a search function to query result fron sql server for paging . I declare an Entity named “Product” inherit from ISoftDelete , my service injection IRepository<Product,long> _productRepository ,as my requirement I write my code as follows:
var query = _productRepository.GetAll() .WhereIf(input.ModelId.HasValue, u => u.ModelId == input.ModelId) .WhereIf(input.CategoryId.HasValue, u => u.CategoryId == input.CategoryId) .OrderByDescending(t => t.Id).PageBy(input); var result = await query.ToListAsync(); var productCount = await query.CountAsync();
then i use “sqlserver profiler” to catch generated script is out of my expectation. generates the following query:
exec sp_executesql N'SELECT [s].[Id], [s].[Code], [s].[Name] FROM [Products] AS [s] WHERE ([s].[IsDeleted] = 0) OR ([s].[IsDeleted] <> @__IsSoftDeleteFilterEnabled_0)',N'@__IsSoftDeleteFilterEnabled_0 bit',@__IsSoftDeleteFilterEnabled_0=1
(as the same as await query.CountAsync();
)
it seems DbContext excute paging after load all records from sqlserver into memory but not excute paging by sql server.this is the question .when my table have 2+ million records. my IIS service may be dead. how can we solve the problem?
Issue Analytics
- State:
- Created 6 years ago
- Reactions:1
- Comments:10 (5 by maintainers)
Top GitHub Comments
@ismcagdas my all code are based on ABP 3.0.0 , I will upgrade to ABP 3.4 to test it later.
yes,it’s great! I have replace those code in source of abp 3.0.0 to test result goes fine. thxs again.