는 방법을 결정하는 크기를 바이트 단위의 결과는 에서 설정 LINQ to SQL
-
01-07-2019 - |
문제
을 작성할 때 매뉴얼 SQL 그것의 아주 쉽게 예상의 모양과 크기에 의해 반환되는 데이터 쿼리를 수행합니다.저는 점점 더 열심히 찾을 수행한 이 LINQ SQL 쿼리를 처리합니다.때때로 내가 찾는 방법보다 더 많이 했을 기대할 수 있는 정말 원격 클라이언트에 액세스하는 데이터베이스를 직접 있습니다.
싶을 수 있는 쿼리를 실행하고 다음 정확히 얼마나 많은 데이터가 반환에 걸쳐 철사,그리고 이것을 사용하는 데 도움이 나를 최적화 할 수 있습니다.
나는 이미를 엮은 로그를 사용하여 매핑되는.로그인 방법이지만,그만이 나에게 표시 SQL,전송되는 데이터 받았습니다.
Any tips?
해결책
다른 팁
참고:당신이 필요 캐스팅을 연결하렇게 하려면 다음과 같이 있을 경우에는 기존 매핑되는
((SqlConnection)dc.Connection).StatisticsEnabled = true;
다음 검색으로 통계:
((SqlConnection)dc.Connection).RetrieveStatistics()
내가 찾는 방법은 없을 잡아렇게 하려면 다음과 같이의 매핑되는,그래서 내가 만들어 이렇게 하려면 다음과 같이 수동:
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();
제휴하지 않습니다 StackOverflow