0

I have start date and end date input from user. When user key in start date and end date and click search button, the query will then check against database which return list of item that is available in that specified date range. How can it be done in linq?

Below show the table and further explaination.

Image

Updated code, i joined two tables but it seems that i am unable to compare start date and enddate as linq to entities does not support datetime.

searchItem = db.Items.Join(db.ItemReserveds, x => x.ItemID, y => y.ItemID, (x,y) => new {x = x, y = y}).Where(
        z => (z.x.ItemID == z.y.ItemID).Select(z => new Item {
            ....
        }).Distinct();
    searchItem = searchItem.Where(z.StartDate >= model.StartDate && z.EndDate <= model.EndDate); 
3

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Browse other questions tagged or ask your own question.