Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Deleting bulk items by ID (e.g. Integrating Extended Entity Framework Features?) #7011

Closed
chrispepper1989 opened this issue Nov 14, 2016 · 1 comment

Comments

@chrispepper1989
Copy link

chrispepper1989 commented Nov 14, 2016

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)

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....

@rowanmiller
Copy link
Contributor

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.

@ajcvickers ajcvickers reopened this Oct 16, 2022
@ajcvickers ajcvickers closed this as not planned Won't fix, can't repro, duplicate, stale Oct 16, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants