c# - Is there a way to get size of data commited to database by LINQ query? -


i writing example program test database connection performance (mysql, oracle, mssql).

all data prepared , queued using: insertonsubmit() pushed db using:

datetime dbinsertstarttime = datetime.now; db.submitchanges() ; datetime dbinsertstoptime = datetime.now; 

i able time of operation in milliseconds.

how size of data queued or written db?

the program allows user define number of data (like 10 data type a, 4 type b etc.) generated, not amount should simulate real working conditions.

therefore know how many data generated.

the datacontext has getchangeset() method returns changeset containing objects have been added, modified or removed - 1 collection each. little more linq can separate them types , count them see how many of each type there are.

also, it'snotalie notes in comments, when timing operations should use system.diagnostics.stopwatch instead of datetime; has better precision.

note:

this answer refers linq-to-sql's datacontext. using entity framework, dbcontext.savechanges() returns int indicating how many entities affected, , can use savingchanges event inspect objectstatemanager , object states way.


Comments

Popular posts from this blog

image - ClassNotFoundException when add a prebuilt apk into system.img in android -

I need to import mysql 5.1 to 5.5? -

Java, Hibernate, MySQL - store UTC date-time -