Jasinski Technical Wiki

Navigation

Home Page
Index
All Pages

Quick Search
»
Advanced Search »

Contributor Links

Create a new Page
Administration
File Management
Login/Logout
Your Profile

Other Wiki Sections

Software

PoweredBy

Page History: SQL Statement used by LINQ

Compare Page Revisions



« Older Revision - Back to Page History - Newer Revision »


Page Revision: Mon, Jun 20, 2011, 2:22 PM


LINQ-to-SQL

To send it to the Console.

using (NorthwindDataContext context = new NorthwindDataContext())
{          
    context.Log = Console.Out;

    Customer customer = context.Customers.Single<Customer>
                       (c => c.CustomerID.Equals("ALFKI"));
}

To send it to the debugger output window. (DebuggerWriter is a wrapper around System.Diagnostics.Debugger.
using (NorthwindDataContext context = new NorthwindDataContext())
{          
    context.Log = new DebuggerWriter();

    Customer customer = context.Customers.Single<Customer>
                        (c => c.CustomerID.Equals("ALFKI"));
}

Entity Framework

IQueryable<Product> q = from o in . . .

string sql = ((ObjectQuery<Product>)q).ToTraceString();

ScrewTurn Wiki version 3.0.1.400. Some of the icons created by FamFamFam. Except where noted, all contents Copyright © 1999-2024, Patrick Jasinski.