I'm working on my exam project and I'm struggling with creating a method which returns filtered list of orders. I'm trying to filter the by DateTime func which I previously saved in database with code first variant and after filtering it to call the method in WindowsForm gridview.
I tried multiple ways which I saw around the internet but nothing worked
public IQueryable<Order> GetOrderFiltered(IQueryable<Order> OrdersQuery, Order order)
{
if (!string.IsNullOrWhiteSpace(order.Time))
{
OrdersQuery = OrdersQuery.Where(p => p.Time.Contains(DateTime.Today.ToString("dd/MM/yyyy HH:mm")));
}
var list = new List<Order>(OrdersQuery);
return list;
}
}
namespace Data.Model
{
public class Order
{
[Key]
public int Id { get; set; }
public string Name { get; set; }
public string Product { get; set; }
public string PhoneNumber { get; set; }
public string Location { get; set; }
public DateTime Time { get; set; }
}
}
I would be very thankful if someone could help me.