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 6471591
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T06:14:31+00:00 2026-05-25T06:14:31+00:00

I need to add this simple statement to each SQL query, per table: WHERE

  • 0

I need to add this simple statement to each SQL query, per table:

WHERE Deleted = 0

Is there any easy way of doing? I mean I need to filter all records, preferrably in the edmx file.

  • 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-05-25T06:14:31+00:00Added an answer on May 25, 2026 at 6:14 am

    Sounds like you want to add a WHERE to your object sets by default. I don’t know if you can do that by default, but a couple ways I can think of to accomplish this are:

    1) Use views to give you the WHERE clause and build your entities off the views. I’ve never actually done this, so I don’t know how well views work with EF – if you need to write back to the database, this probably wouldn’t work well.

    2) Create new properties in a partial class of your EDMX, like:

    partial class MyEntities
    {
        public IQueryable<Foo> ActiveFoos
        {
            return Foos.Where(f => f.Deleted == 0);
        }
    }
    ...
    using (var context = new MyEntities())
    {
        var foo = context.ActiveFoos.Where(f => f.Id == 1).SingleOrDefault();
    }
    

    3) Create a child context class and new out the properties – kind of ugly, but this would be reasonably transparent to the developer once it’s built.

    public class CustomEntities : MyEntities
    {
        public new IQueryable<Foo> Foos
        {
            get { return base.Foos.Where(f => f.Deleted == 0); }
        }
    }
    ...
    using (var context = new CustomEntities())
    {
        var foo = context.Foos.Where(f => f.Id == 1).SingleOrDefault();
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Getting very annoyed with this simple query... I need to add an offset to
I need to add indexes to my table (columns) and stumbled across this post:
Hello i am trying to do this simple statement but i want to add
I need to add authentication to this function: function multiRequest($data, $options = array()) {
I have a java.util.Set<City> cities and I need to add cities to this set
I need to add and delete class on an element having multiple classes: This
I need to add default value column in SqlServer Compact....i am new to this
I need to add a dependency on a specific version of GDIPlus. This is
Basically this code below returns the right information, but I need to add the
I need to position this update button on www.euroworker.no/order (you'll have to add an

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.