我想从第一个选择中返回ProductDetailViewModel的列表,但我似乎没有做任何工作。结合两个选择的正确方法是什么?
var test = (from pc in db.PartnerCoupons
from coup in db.Coupons
where pc.CouponID == coup.CouponID
&& pc.PartnerCampaignID == partCamp.PartnerCampaignID
&& coup.CategoryID == id
select pc).ToList();
var partnerCoupons = from pc in test
.Select(s => new ProductDetailViewModel(s))
.ToList()
select pc;
return View("List", partnerCoupons);
为了清楚起见,这项工作我只是想摆脱“partnercoupons” - 选择。
/麦克
答案 0 :(得分:0)
试试这个:
返回视图(“List”,partnerCoupons.ToList());
答案 1 :(得分:0)
var coupons = from pc in db.PartnerCoupons
from coupon in db.Coupons
where pc.CouponID == coupon.CouponID
&& pc.PartnerCampaignID == partCamp.PartnerCampaignID
&& coupon.CategoryID == id
select new ProductDetailViewModel (pc);
return View ("List", coupons.ToList ());