SELECT

  1. selectQuery.Select(f => f.Column("ProductID"))
  2.     .From(f => f.Table("Order Details"));

Output (MS SQL)

  1. SELECT
  2.     [ProductID]
  3. FROM
  4.     [Order Details]
  5. WHERE
  6.     ([ProductID] > @p0)

 

SELECT with where clause

  1. selectQuery.Select(f => f.Column("ProductID"))
  2.     .From(f => f.Table("Order Details")).Where(e => e.Column("ProductID") > 10);

 

Output (MS SQL)

  1. SELECT
  2.     [ProductID]
  3. FROM
  4.     [Order Details]
  5. WHERE
  6.     ([ProductID] > @p0)

SELECT with sub query

  1. selectQuery.Select(e => e.Column("ProductID"))
  2.     .From(e => e.Table("Order Details", "od"))
  3.     .Where(
  4.         f =>
  5.         f.Exists(                       
  6.                 f.Select(f.Constant(1)).From(f.Table("Orders", "o"))
  7.                 .Where(f.Column("o","OrderId") == f.Column("od","OrderID"))));

Output (MS SQL)

  1. SELECT
  2.     [ProductID]
  3. FROM
  4.     [Order Details] AS od
  5. WHERE
  6.     EXISTS(SELECT
  7.     @p0
  8. FROM
  9.     [Orders] AS o
  10. WHERE
  11.     ([o].[OrderId] = [od].[OrderID]))

 

SELECT using a derived table

  1. selectQuery.Select(e => e.Column("ProductID"))
  2.     .From(f => f.Table("Order Details", "od"))
  3.     .InnerJoin(
  4.         f =>
  5.         f.Alias(f.Select(f.Column("OrderID")).From(f.Table("Orders")).Where(f.Column("OrderID") == 1), "o"),
  6.         f => f.Column("od","OrderID") == f.Column("o","OrderID"));

Output (MS SQL)

  1. SELECT
  2.     [ProductID]
  3. FROM
  4.     [Order Details] AS od INNER JOIN (SELECT
  5.     [OrderID]
  6. FROM
  7.     [Orders]
  8. WHERE
  9.     ([OrderID] = @p0)) AS o ON ([od].[OrderID] = [o].[OrderID])

Last edited Jan 24, 2011 at 5:24 PM by seesharper, version 3

Comments

No comments yet.