如何返回此查询值
我将加入查询实现以加入两个表。如何返回这些值。
public List<cartItem> getcartItem(int userId)
{
var data = (from c in _context.cartItems join p in _context.Products
on c.productId equals p.ProId
where c.userId == userId && c.status==false select new {
proName=p.ProductName,
qty=c.quantity,
proImg=p.ImageUrl,
uPricce=p.price
}).ToList();
return data;
}
I implement the join query for join two tables. How to return those values.
public List<cartItem> getcartItem(int userId)
{
var data = (from c in _context.cartItems join p in _context.Products
on c.productId equals p.ProId
where c.userId == userId && c.status==false select new {
proName=p.ProductName,
qty=c.quantity,
proImg=p.ImageUrl,
uPricce=p.price
}).ToList();
return data;
}
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
假设这些是Cartitem OBJ的属性,您只需要分配选择语句即可匹配返回类型和新的Cartitem。
Assuming these are the properties of a cartItem obj, you just need to assign the select statement to match the return type and new up a cartItem.