score:2

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

score:0

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 http://msdn.microsoft.com/en-us/library/7h2ahss8(VS.80).aspx
string bytesSent = sqlConnection.RetrieveStatistics()["BytesSent"].ToString();
string bytesReceived = sqlConnection.RetrieveStatistics()["BytesReceived"].ToString();

score:1

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 :

 ((SqlConnection)dc.Connection).RetrieveStatistics()

Related Query

More Query from same tag