Accepted answer

Looks like you can grab the SqlConnection of your DataContext and turn on statistics.

One of the statistics is "bytes returned".

MSDN Reference Link


I found no way to grab the SqlConnection of the DataContext, so i created the SqlConnection manually:

SqlConnection sqlConnection = new SqlConnection("your_connection_string");
// enable statistics
cn.StatisticsEnabled = true;

// create your DataContext with the SqlConnection
NorthWindDataContext nwContext = new NorthWindDataContext(sqlConnection);

var products = from product in nwContext
               where product.Category.CategoryName = "Beverages"
               select product;
foreach (var product in products)
    //do something with product

// retrieve statistics - for keys see
string bytesSent = sqlConnection.RetrieveStatistics()["BytesSent"].ToString();
string bytesReceived = sqlConnection.RetrieveStatistics()["BytesReceived"].ToString();


Note: You need to cast the connection to a SqlConnection if you have an existing DataContext

 ((SqlConnection)dc.Connection).StatisticsEnabled = true;

then retrieve the statistics with :


Related Query

More Query from same tag