You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Reason I ask is I am currently getting full models back just to delete them, here is a simplified version of what I am doing (effectively we don't, and can't, have cascading foreign keys in the DB)
void DeleteChildren(IModel model)
{
var children = Context.Where(o => o.OwnderID == model.Id)
foreach (var child in children)
{
CallDeleteOnChildren(existingModel); //Call delete on each child, effectively recursive
ModelContext.Current.Entry(existingModel).State = EntityState.Deleted;
}
ModelContext.Current.SaveChanges();
}
virtual CallDeleteOnChildren(IModel model){}
//which might be overiden like
virtual CallDeleteOnChildren(IModel model)
{
Items1.DeleteChildren(model);
Items2.DeleteChildren(model);
//etc
}
I would just use the library above, but it looks like its no longer maintained and I don't want to bring an unmaintained library into the codebase. But effectively I am imagining that this would be quicker:
void DeleteChildren(IModel model)
{
var children = Context.Where(o => o.OwnderID == model.Id).Select(o => o.id);
foreach (var child in children)
{
CallDeleteOnChildren(existingModel); //Call delete on each child, effectively recursive
}
Context.Where(s => children.contains(s.Id)).Delete();
}
Of course this might be a chicken before the egg problem....
The text was updated successfully, but these errors were encountered:
We've got the feature on our backlog (#795). It's not something we are planning to do in the immediate future, but we do think it would be a good feature to have.
Apologies if this is the wrong place to raise this but I was wondering if there have been any plans to integrate features from:
https://github.com/loresoft/EntityFramework.Extended
Reason I ask is I am currently getting full models back just to delete them, here is a simplified version of what I am doing (effectively we don't, and can't, have cascading foreign keys in the DB)
I would just use the library above, but it looks like its no longer maintained and I don't want to bring an unmaintained library into the codebase. But effectively I am imagining that this would be quicker:
Of course this might be a chicken before the egg problem....
The text was updated successfully, but these errors were encountered: