You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Hi,
I have a Blazor Server Application, I am querying database based on start and end dates as follows.
`await using var ctx = await _db.CreateDbContextAsync();
IQueryable<ReportViewModel> result = from o in ctx.Orders
join c in ctx.Customers on o.CustomerId equals c.Id
join od in ctx.OrdersDetail on o.Id equals od.Order.Id
join v in ctx.Vendors on od.Vendor.Id equals v.Id
orderby o.Id descending
select new ReportViewModel()
{
OrderId = o.Id,
OrderDateTime = o.OrderDateTime.Date,
CustomerId = o.CustomerId,
Status = o.Status,
DoneBy = o.DoneBy,
OrderDetailId = od.Id
};
if (startDateTime != null)
{
result = result.Where(
dt => dt.OrderDateTime >= DateTime.ParseExact(startDateTime.ToString(), "dd.MM.yyyy 00:00:00", null));
}
if (endDateTime != null)
{
result = result.Where(
dt => dt.OrderDateTime <= DateTime.ParseExact(endDateTime.ToString(), "dd.MM.yyyy 00:00:00", null));
}`
I wonder how can I select multiple dates (date picker) and use it in my query?
Thanks in advance.
The text was updated successfully, but these errors were encountered:
Hello @raysefo
You may use one of the examples for multiple dates, either the Range one or the Multiple whichever fits your needs best.
As for picking up the multiple dates, there's a parameter and respective eventcallback for binding the multiple dates, called Dates.
You can use either
@bind-Dates="Dates"
or just Dates="Dates" DatesChanged="DatesChanged"
According to your needs.
Granted the Dates api is missing from the docs, we'll update them accordingly.
Let us know if this helps you.
Hi @David-Moreira
Thank you for your reply. In either case, @bind-Dates="Dates" or Dates="Dates" DatesChanged="DatesChanged" I should change my query, right? What does Dates return? Selected dates with a comma between?
Hello @raysefo I didn't quite look at your query since that's your job... :) But from a shallow look seems fine? You might want to query the dates in the EF Core query itself, so it already brings the data from the database filtered by dates instead of bringing the data to memory and only then filtering by the dates.
As for the Dates Parameter, it's a List of Dates, IReadOnlyList<DateTime?> as you'd expect.
If you are not able to get it to work, just post the code that you are trying to use here, we'll help.
Hi,
I have a Blazor Server Application, I am querying database based on start and end dates as follows.
I wonder how can I select multiple dates (date picker) and use it in my query?
Thanks in advance.
The text was updated successfully, but these errors were encountered: