c# - Speed up model instantiation for EF6 / sqlite db -


i have large collection of 12000 data entries example , want insert them via ef6 sqlite database. time consumes the instantiation of data models:

at moment loop 12000 times 'new myitem()'

downloaded12000items.foreach(result =>{     var myitem= new myitem     {         id = result.id,         description = result.description,         property1 = result.property1     }     resultlist.add(myitem); });  unitofwork.itemrepository.insertrange(resultlist); 

how can speed instantiation of models or there maybe way insert data faster sqlite database?

edit: have explain problem better. bottleneck not insert() database. use ef6 .insert(somemodel) have create instance of modelclass of entity. have 12000 times, instantiation of 12000 modelclasses takes time.

my question was, there possibility fasten instatiation process of model classes, maybe cloning or else?

or, there maybe chance insert data sqlite db without using .insert(somemodel), maybe using direct sql command or else? skipping model instantiation helpful...

the bottleneck adding of entities context.

unitofwork.itemrepository.insert(myitem); 

at first doesn't take time, after 100s or 1000 records, does.

see this answer other optimizations might able add (read comments of linked answer!).


Comments

Popular posts from this blog

amazon web services - S3 Pre-signed POST validate file type? -

c# - Check Keyboard Input Winforms -