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); 
stackdisplay
  • 1,949
  • 6
  • 29
  • 46
  • 4
    Please show some effort doing homework and ask specific question if you get stuck – display name Jan 25 '15 at 14:55
  • You've asked a few question now on Stack Overflow and you seem to have a history of not providing your efforts to date. Please read through http://stackoverflow.com/help/how-to-ask. – David L Jan 25 '15 at 14:58
  • possible duplicate of [Using DateTime in LINQ to Entities](http://stackoverflow.com/questions/16736252/using-datetime-in-linq-to-entities) – t3chb0t Jan 27 '15 at 10:50

0 Answers0