What's the convention for extending Linq with set based helper operations
- by Luke Rohde
Hi All
I might be vaguing out here but I'm looking for a nice place to put set based helper operations in linq so I can do things like;
db.Selections.ClearTemporary()
which does something like
db.DeleteAllOnSubmit(db.Selections.Where(s => s.Temporary))
Since I can figure out how to extend Table<Selection> the best I can do is create a static method in partial class of Selection (similar to Ruby) but I have to pass in the datacontext like;
Selection.ClearTemporary(MyDataContext)
This kind of sucks because I have two conventions for doing set based operations and I have to pass the data context to the static class.
I've seen other people recommending piling helper methods into a partial of the datacontext like;
myDataContext.ClearTemporarySelections();
But I feel this makes the dc a dumping ground for in-cohesive operations.
Surely I'm missing something. I hope so. What's the convention? TIA