question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Soft delete filter problem In ef core Performance/generates script

See original GitHub issue

Now 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:closed
  • Created 6 years ago
  • Reactions:1
  • Comments:10 (5 by maintainers)

github_iconTop GitHub Comments

2reactions
ryansixcommented, Mar 2, 2018

@ismcagdas my all code are based on ABP 3.0.0 , I will upgrade to ABP 3.4 to test it later.

1reaction
ryansixcommented, Mar 9, 2018

yes,it’s great! I have replace those code in source of abp 3.0.0 to test result goes fine. thxs again.

Read more comments on GitHub >

github_iconTop Results From Across the Web

How to Implement a Soft Delete Strategy with Entity ...
Automatically filter soft-deleted records​​ Marking records to be deleted is only half the story. With a single configuration, you can tell EF ......
Read more >
Entity Framework Core: Soft Delete using Query Filters
To apply the soft-delete to all entities of the model, you can iterate over all entity types and add the property and the...
Read more >
EF Core In depth – Soft deleting data with Global Query ...
This article is about a way to seemingly delete data, but in fact EF Core hides it for you and you can get...
Read more >
Ef core global query filters. 0 default value for common propert
Global query filters introduced by Entity Framework Core 2 provide us with ... Soft delete filter problem In ef core Performance/generates script #2980....
Read more >
Soft Deleting in Entity Framework Core – When & How
Typically, soft deleting involves something along the lines of adding an isDeleted column to the database table that represents the model you ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found