DataContext.GetCommand(IQueryable) DataContext.GetCommand(IQueryable) DataContext.GetCommand(IQueryable) DataContext.GetCommand(IQueryable) Method


LINQ to SQLLINQ to SQL에서 생성한 SQL 명령에 대한 정보를 가져옵니다.Gets the information about SQL commands generated by LINQ to SQLLINQ to SQL.

 System::Data::Common::DbCommand ^ GetCommand(System::Linq::IQueryable ^ query);
public System.Data.Common.DbCommand GetCommand (System.Linq.IQueryable query);
member this.GetCommand : System.Linq.IQueryable -> System.Data.Common.DbCommand
Public Function GetCommand (query As IQueryable) As DbCommand

매개 변수

IQueryable IQueryable IQueryable IQueryable

SQL 명령 정보를 검색할 쿼리입니다.The query whose SQL command information is to be retrieved.


요청된 명령 정보 개체입니다.The requested command information object.


// using System.Data.Common;
Northwnd db = new Northwnd(@"c:\northwnd.mdf");

var q =
    from cust in db.Customers
    where cust.City == "London"
    select cust;

Console.WriteLine("Customers from London:");
foreach (var z in q)
    Console.WriteLine("\t {0}",z.ContactName);

DbCommand dc = db.GetCommand(q);
Console.WriteLine("\nCommand Text: \n{0}",dc.CommandText);
Console.WriteLine("\nCommand Type: {0}",dc.CommandType);
Console.WriteLine("\nConnection: {0}",dc.Connection);

' Imports System.Data.Common

Dim db As New Northwnd("c:\northwnd.mdf")

Dim q = _
From cust In db.Customers _
Where cust.City = "London" _
Select cust

Console.WriteLine("Customers from London:")
For Each z As Customer In q
    Console.WriteLine(vbTab & z.ContactName)

Dim dc As DbCommand = db.GetCommand(q)
Console.WriteLine(vbNewLine & "Command Text: " & vbNewLine & dc.CommandText)
Console.WriteLine(vbNewLine & "Command Type: {0}", dc.CommandType)
Console.WriteLine(vbNewLine & "Connection: {0}", dc.Connection)



이 메서드는 getter만 이며 영향을 주지 않습니다 DataContext 상태입니다.This method is only a getter and does not affect DataContext state.

다음 고려 사항을 note 합니다.Note the following considerations:

  • 인수는 null 이어야 합니다.The argument must be non-null. 그렇지 않으면 null 인수 예외를 throw 됩니다.Otherwise, a null argument exception is thrown.

  • 발생 하는 일반적인 쿼리 변환 예외 LINQ to SQLLINQ to SQL 변환할 수 없는 쿼리에 대 한 쿼리 실행 적용 합니다.Normal query translation exceptions thrown during LINQ to SQLLINQ to SQL query execution apply for a query that cannot be translated.

  • 첫 번째 쿼리 명령은 반환 됩니다.Only the first query command is returned. 즉시 로드에 사용 되는 추가 명령이 특히 (LoadWith)는 포함 되지 않습니다.Specifically, additional commands that are used for eager loading (LoadWith) are not included.

  • DataContext 명령을 사용 하 여 사용자가 추적 하지 않습니다.DataContext does not track what the user does with the command. 예를 들어, 반환 된 명령을 실행 한 결과는 추적 되지 않습니다 하 고 영향을 주지 않습니다 DataContext 상태입니다.For example, results from the execution of the returned command are not tracked and do not affect DataContext state.

적용 대상