Try .NET /elinq/
Powered by Try .NET

SQL Server SELECT TOP

2) Using TOP to return a percentage of rows

var query = DbContext.Products.Query((Products products) =>
{
    var result = SELECT(TOP(1).PERCENT().Of(products));
    FROM(products);
    ORDER(BY(products.ListPrice).DESC);

    return result;
});

foreach (var product in query)
    Console.WriteLine((product.ProductName, product.ListPrice));

3) Using TOP WITH TIES to include rows that match the values in the last row

var query = DbContext.Products.Query((Products products) =>
{
    var result = SELECT(TOP(3).WITH_TIES().Of(products));
    FROM(products);
    ORDER(BY(products.ListPrice).DESC);

    return result;
});

foreach (var product in query.Take(6))
    Console.WriteLine((product.ProductName, product.ListPrice));

< BACK | HOME