Hello I have a C# lambda expression looks like it should work to me but its returning nothing.
CategoryItems = (db.Items.Include("Pictures").Join(db.Rentals,
i => i.itemID,
r => r.ItemID,
(i, r) => new { Item = i, Rental = r })
.Where(ir => ir.Item.CategoryID == CategoryID && ir.Rental.RentedBy == 0)
.OrderByDescending(ir => ir.Item.ListDate)
.Select(i => new DisplayItem()
{
AvailableForPurchase = i.Item.AvailableForPurchase,
Description = i.Item.Description == string.Empty ? "No Description" : i.Rental.Title,
PostDate = i.Item.ListDate,
PostedBy = i.Item.User.UserName,
PricePerDay = i.Rental.RentalPrice ?? 0.00m,
ItemID = i.Item.itemID,
PhotoURL = i.Item.Pictures.FirstOrDefault().PictureLink
})).ToPagedList(page, 5);
Any help appreciated
var CategoryItems =
from item in db.Items
join rental in db.Rentals on item.itemID equals rental.ItemID
where item.CategoryID == CategoryID && rental.RentedBy == 0
orderby item.ListDate descending
select new DisplayItem
{
AvailableForPurchase = item.AvailableForPurchase,
...
};
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.