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".
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()
Source: stackoverflow.com
Related Articles
- How to determine size in bytes of a result set from LINQ to SQL
- creating Linq to sqlite dbml from DbLinq source code
- c# Linq or code to extract groups from a single list of source data
- Filling a DataSet or a DataTable from a LINQ query result set
- Select top 1 result from subquery in linq to sql
- Returning a single property from a LINQ query result
- Enumerable.Empty<T>().AsQueryable(); This method supports the LINQ to Entities infrastructure and is not intended to be used directly from your code
- Using Linq on a Client Object model result from sharepoint
- How to understand the following C# linq code of implementing the algorithm to return all combinations of k elements from n
- How to pass LinQ Expressions from F# to C# code
- Return one result from LINQ Query
- Using LINQ to delete an element from a ObservableCollection Source
- How does linq actually execute the code to retrieve data from the data source?
- how to get all columns from a linq result with a join
- LINQ Source Code Available
- Is there a bug in this code from 101 LINQ Samples on MSDN? (Update: Fixed)
- Determine the source DataContext for a Linq to Sql query
- Retrieve bool result by using LinQ code
- Getting the first result from a LINQ query - why does ElementAt<T>(0) fails when First<T>() succeeds?
- Linq result from many tables into an inherit class with nested classes
- C# LINQ How to get a data source from a db?
- Getting single result from a query with anonymous types in Linq To Sql
- To determine if one of the Strings from a list contains the initial part of a specified string using LINQ
- Using LINQ query result for data source for GridControl c#
- Send a new list to the result of the LINQ query from the list for C#
- SQL subquery result in LINQ and Entity Framework Code First
- Using LINQ how do I concatenate bytes from SortedDictionary<string,List<byte[]>>
- What is the underlying type of the result from a Linq to Entities query?
- LINQ deferred execution with a function's result as source (e.g. Console.ReadLine)
- Linq query doesn't return a result from object within another object
- Getting Count from Grouped DataTable in VB via Linq
- Casting a nullable in where clause in LinQ-to-entity without null-check
- Linq .FirstOrDefault not working
- What options do I have for LINQ projections?
- ASP.NET search form - dynamic Linq to SQL?
- Accessing a member of an anonymous type during construction
- Pattern for Multi User ASP.NET with SQL/LINQ
- Getting the incorrect count from a LINQ query
- LINQ Query to traverse treeview and get data
- Group by List in LINQ
- Compare two json array in c# and get only the difference in separate object
- Get Ids that match specific column values for the same column Id
- Linq max giving inappropriate max value from table
- The ':' character, hexadecimal value 0x3A, cannot be included in a name
- How do I use LINQ-to-Entities to insert data into a specific table?
- C# - group list by TimeSpan starting from specific start point
- Repeat numbers in List/IEnumerable
- PgAdmin Import/Export did not keep foreign keys with Entity Framework
- Linq - How to Use NOT IN
- convert List<DataRow> to List<UserEntity> in C#.net