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.
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
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.
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:
3) Create a child context class and
newout the properties – kind of ugly, but this would be reasonably transparent to the developer once it’s built.