Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9307931
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 19, 20262026-06-19T00:30:10+00:00 2026-06-19T00:30:10+00:00

What is the elegant way of the soft delete on EntityFramework ? I have

  • 0

What is the elegant way of the soft delete on EntityFramework? I have already identified a property (database field) as deleted and always use this filter on linq statements.

Like

Foo Class  
  int NumberField  
  string Description 
  bool Deleted

contexts.Foos.Where(x=> !x.Deleted);

It is not feasible on complex queries.

I just looked these solutions..
Link 1, Link 2

Any help appreciated..

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-19T00:30:11+00:00Added an answer on June 19, 2026 at 12:30 am

    Yes this possible with EF via pattern.
    If you use a Fascade/repository pattern and access EVERY time via that fascade.

    eg
    an implementation of an interface on ALL repository classes might look like this:

     class MyRepositoryBase<T>....
    
        public IQueryable<T> ValidQuerySet  // this is not deleted check  Set
    
        {  get {  return Context.Set<T>().Where(t => t.deleted != true);
               }
        }
    

    You would access exactly as if it was the original DbSet.
    EF will combine the conditions.

    var myQuerySet = MyRespository<T>.ValidQuerySet.Where(t=>t.foo == "bar");
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

What would be an elegant way of doing this? I have this -> MC0001
Is there a more elegant way of doing this sort of thing? I have
Is there a more elegant way to accomplish this. I have a string, where
Is there an elegant way to have performant, natural sorting in a MySQL database?
What is the most elegant way to implement this function: ArrayList generatePrimes(int n) This
Is there an elegant way to do this in MySQL: SELECT (subquery1) AS s1,
Is there a more elegant way to do this: widget.notes.where(:author_id => a).first.message= widget.notes.where(:author_id =>
Is there an elegant way to delete all non-selected entries from a table after
Is this the most elegant way to express a isPrime function for BigInt objects?
Is there an elegant way of doing this? Perhaps with Linq? For something like

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.