I have a LINQ statement which is returning incorrect data.
I need to select each product which is active, and have the prices displayed according to the usertype logged in. (Each user type has a different price)
I currently have five acive items in the database, but only two are showing.
public IQueryable GetProductsForListViewByUserType(Guid userTypeID)
{
return
(from p in this.Entities.Product
join b in this.Entities.Brand on p.BrandID equals b.ID
join ut in this.Entities.UserTypePrice on p.ID equals ut.ProductID
where p.Active == true && ut.UserTypeID == userTypeID
select new
{
p.ID,
p.Name,
Price = ut.Price,
p.Description,
BrandName = b.Name,
p.Colour,
p.ImageURL
});
}
Not all active items are being returned from the query.
Personally, the statement syntax seems to be fine. But I would like to know other people's views about this.
I debugged the statement, that's why I know that the problem is within the statement itself.
我的建议是问题出在userTypeID
,如果Entities.UserTypePrice
缺少该产品,则不会退货。
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.