DAY()
function with table columns example(we took the SQL Server DAY Function for example)
var year = 2017;
var month = 2;
var query = DbContext.Set<GrossSalesByDay>()
.Query((Orders orders, OrderItems orderItems, GrossSalesByDay alias) =>
{
var grossSales = SUM(orderItems.ListPrice * orderItems.Quantity);
var shippedDay = orders.ShippedDate?.Day;
var r = SELECT<GrossSalesByDay>(shippedDay.@as(alias.Day),
grossSales.@as(alias.GrossSales));
FROM(orders).JOIN(orderItems).ON(orderItems.Order == orders);
WHERE(orders.ShippedDate != null &&
orders.ShippedDate?.Year == year &&
MONTH(orders.ShippedDate) == month);
GROUP(BY(shippedDay));
return r;
})
.OrderBy(gs => gs.Day);
foreach (var grossSalesByDay in query.Take(3))
Console.WriteLine((grossSalesByDay.Day, grossSalesByDay.GrossSales));
ELINQ maps the
DateTime
properties to the corresponding SQL functions, but a "direct" call is supported as well (line 16).