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 Query
- How to determine size in bytes of a result set from LINQ to SQL
- How to set Sql DateTime to null from LINQ
- How to Iterate over an XML Element result set from a Linq Query
- How to write SQL and LINQ to get the one record from a result with where condition?
- How to create result set from Linq with enumerable types?
- How to assign two different entities result set into single var variable using linq to sql c#
- Multiple result set from SQL Via LiNQ
- Filling a DataSet or a DataTable from a LINQ query result set
- How are people unit testing code that uses Linq to SQL
- How to return anonymous type from c# method that uses LINQ to SQL
- how to see generated sql from a linq query
- How to write linq query to match SQL like select top 100 * from tab?
- Select top 1 result from subquery in linq to sql
- How can I set properties on all items from a linq query with values from another object that is also pulled from a query?
- How to use LINQ to find all combinations of n items from a set of numbers?
- How to understand the following C# linq code of implementing the algorithm to return all combinations of k elements from n
- Linq to SQL - How to sort results from query
- How to move from LINQ to SQL to "LINQ to WCF"?
- How to pass LinQ Expressions from F# to C# code
- How can I achieve SQL CASE statement from LINQ
- 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
- c#: how to set combobox valuemember from linq query
- How can I determine if a LINQ query is going to be LINQ to SQL vs. LINQ to Objects?
- How to Bind Exclude more than one property from a model with linq to sql asp.net mvc
- How do i prevent Linq from adding a GUID so that SQL server can do it?
- How to code the partial extensions that Linq to SQL autogenerates?
- How to get Multiple Result Set in Entity Framework using Linq with C#?
- Determine the source DataContext for a Linq to Sql query
- How to get SQL query into LINQ form in C# code
More Query from same tag
- Have a Query want it in LINQ(Inner Join)
- An expression tree may not contain an assignment operator?
- Linq expression with multiple input parameters
- comparing equality 2 lists resulting from entity framework query result in c#
- Having an issue with a null exception on WPF DataGrid when trying to display data from a database with Linq
- Linq Group by id
- How can I retrieve date from this XML request?
- How to get double records using LinQ?
- subquery in LINQ for Update
- Joins with more than 2 or 3 tables, with Where clause using Lambda Expressions. Then sending the object to the View
- How to generate array of objects after LINQ to xml in C#
- Desktop application using LINQ to SQL, Dynamically Create a Database, and creating install app
- LINQ and removing duplicates from an array of objects
- Are LINQ to Entites 4.0 Queries Compiled By Default?
- Specified cast is not valid Linq Query
- LINQ Query C# ASP
- Linq To DataSet getting error
- Linq: Getting a List<String> from List<Customer> based on customer.name
- Linq to entities select records based on subitems
- How do I get values of Linq Expression
- Get a comma separated list of entity collection using linq
- Dynamic Lambda Expression inside an Expression Query
- Check if one IEnumerable contains all elements of another IEnumerable
- What is the best way to get rows from different databases?
- LINQ query with GroupBy causing "Unable to create a constant value of type 'System.Object'..."
- Join two tables with key in common and show on a datagrid c# linq
- Convert SQL to Linq for left join with NULL in right
- Binding the multiple result set from store procedure into one list
- How can I trim all elements in a list?
- Entity Framework setup issue