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
Post a Comment