Hi i'm totally new to EF and i'm having difficulties getting my head around it but heres the scenario. I've created a project and added a edmx diagram which i've used to generate models from a pre-built SQL database. That dame diagram has generated code for each model an a context for me. the context looks something like :
public partial class BuzzEntities : ObjectContext
{
public ObjectSet<Case> Cases
{
get
{
if ((_Cases == null))
{
_Cases = base.CreateObjectSet<Case>("Cases");
}
return _Cases;
}
}
ok so far this allows me to do things like
private Buzz.BuzzEntities db = new BuzzEntities();
db.Cases.DeleteObject(someCase);
which will delete the someCase from the database. However what i would like to do i override the delete method so that instead of deleting the object it marks a property of the object as deleted instead. i.e. someCase.Delete=true; The next part of the system is to prevent the system from loading cases with deleted=true. Basically i dont want the record ever deleted just hidden from the system.
Whats the best way to achieve this? I know i could manually change the field and just save the record instead of calling delete object but i dont want to worry about setting or hiding records in my UI i want the frame work to handle it for me.