So here's my situation:
I'm soft-deleting some rows in a table, using a IsDeleted
flag, so that a can keep a trace of my archived data. I do so by overriding the SaveChanges
statement in my ObjectContext
.
The question is: how can I select only the row(s) that have IsDeleted == false
, without having to specify && !IsDeleted
in every queries?
Is there a way I can specify this on my context directly?
tkx!
You could define a view over your table and query that view instead:
CREATE VIEW dbo.ActiveData
AS
SELECT (list of columns)
FROM dbo.YourTable
WHERE IsDeleted = 0
And then in your EDMX model, read your data from the ActiveData
view instead of the base table.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With