c# - Delete a big list of items with Entity Framework -



c# - Delete a big list of items with Entity Framework -

i want delete big list of items ef, tried remove them 1 1 take long time.

and tried utilize .removeall() method list don't update database [only remove loaded entity]

so utilize sqlcommand remove them database , utilize .removeall() prevent ef unexpected number of rows update (0) exception.

code:

dbcontext.database.executesqlcommand("delete xxx xxx"); loadedentity.subitems.tolist().removeall(r => true); dbcontext.savechanges();

my question: there improve way this?

try

var = dbcontext.xxx.where(x => x.xxx == "xxx"); dbcontext.xxx.removerange(all); dbcontext.savechanges();

c# entity-framework sql-delete

Comments

Popular posts from this blog

assembly - What is the addressing mode for ld, add, and rjmp instructions? -

vowpalwabbit - Interpreting Vowpal Wabbit results: Why are some lines appended by "h"? -

ubuntu - Bash Script to Check That Files Are Being Created -