nyk0r

EF -> SQL

Jun 29th, 2011
139
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
T-SQL 0.77 KB | None | 0 0
  1. -- LINQ expression
  2. var allSchools =
  3.     Context.Schools.
  4.     Include("District.State").
  5.         Where(s => s.Nces == "" || s.Nces == null).ToList();
  6.  
  7.  
  8. -- result
  9. SELECT
  10.     [Extent1].[id] AS [id],
  11.     [Extent1].[nces] AS [nces],
  12.     [Extent1].[name] AS [name],
  13.     [Extent1].[district_id] AS [district_id],
  14.     [Extent2].[id] AS [id1],
  15.     [Extent2].[name] AS [name1],
  16.     [Extent2].[state_id] AS [state_id],
  17.     [Extent3].[fips] AS [fips],
  18.     [Extent3].[abbr] AS [abbr],
  19.     [Extent3].[name] AS [name2]
  20. FROM  
  21.     [dbo].[Schools] AS [Extent1]
  22.     LEFT OUTER JOIN [dbo].[Districts] AS [Extent2]
  23.         ON [Extent1].[district_id] = [Extent2].[id]
  24.     LEFT OUTER JOIN [dbo].[States] AS [Extent3]
  25.         ON [Extent2].[state_id] = [Extent3].[fips]
  26. WHERE
  27.     [Extent1].[nces] = N''
  28.     OR [Extent1].[nces] IS NULL
Advertisement
Add Comment
Please, Sign In to add comment