asp.net - Which is better to use for adding IEnumerable object? -


i have found 2 ways implement add operation on ienumerable objects in repository pattern.

first use .addrange() & pass list in here. or second convert list array & use .addorupdate(arrayobject).

which better use if intension remove foreach loop on ienumerable items? please help.

_context.dbset<myentity>().addorupdate(entities.toarray()); 

or

 _context.dbset<myentity>().tolist().addrange(entities); 

addorupdate can called array of new objects, can create array of type city[] , call context.cityset.addorupdate(cc => cc.id, cityarray); once. in generated sql, there should condition.

in case of performance, read following

https://stackoverflow.com/a/21839455/194345

and following:

context.bulkinsert(hugeamountofentities); 

Popular posts from this blog

c# - ODP.NET Oracle.ManagedDataAccess causes ORA-12537 network session end of file -

matlab - Compression and Decompression of ECG Signal using HUFFMAN ALGORITHM -

utf 8 - split utf-8 string into bytes in python -