var query = (from material in dataContext.Materials
join materialCategories in dataContext.MaterialCategories on material.Id equals
materialCategories.Material.Id
select new
{
material.Id,
material.Name,
material.Taken,
materialCategories.CategoryName
});
//Filter by date
query = query.Where(x => x.Taken >= minDate && x.Taken <= maxDate);
I want to extract the “query.Where(x => x.Taken >= minDate && x.Taken <= maxDate);” to a function that returns a query but the problem is that the function does not understand what x.Taken is.
How do i achieve this?
You need to use a named type instead of an unnamed one.
Make a new class:
You can make fields as properties if you want.
Then instead of:
use your class:
And after that you can have this:
Or use IEnumerable<> depending on what you are doing here exactly.