Common Table Expression (CTE) in linq-to-sql?

AFAIK, this isn’t supported by the object model. However, LINQ supports a method to execute a query (strangly enough called DataContext.ExecuteQuery). Looks like you can use that to call a arbitrary piece of SQL and map it back to LINQ. You won’t be SQL free because of the embedded SQL, but you won’t have to use a sproc.

How to: Directly Execute SQL Queries (LINQ to SQL)

Leave a Comment