Created
July 11, 2013 03:47
-
-
Save phatty/5972390 to your computer and use it in GitHub Desktop.
Left join once in for all
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var Context = new CSPRedemptionEntities(); | |
var List = from cp in Context.CouponPools | |
join cb in Context.CouponBatches | |
on new { CouponBatch_id = cp.CouponBatch_id } equals | |
new { CouponBatch_id = cb.id } | |
join m in Context.Members | |
on new { RedeempBy_id = cp.RedeemBy.Value } equals | |
new { RedeempBy_id = m.id} into MemberLeft | |
from x in MemberLeft.DefaultIfEmpty() | |
where cp.CouponBatch_id == CouponBatch_id && cp.Campaign_id == Campaign_id | |
orderby cp.Seq | |
select new CouponDTO { | |
id =cp.id , | |
Issuer_id =cb.Campaign.Issuer_id , | |
Campaign_id =cp.Campaign_id , | |
Campaign_name =cb.Campaign.Name , | |
CouponBatch_id =cp.CouponBatch_id , | |
Keyid =cp.Keyid , | |
Lot =cp.Lot , | |
Seq =cp.Seq , | |
Check_digit =cp.Check_digit , | |
Generated_id =cp.Generated_id , | |
SerialNo =cp.SerialNo , | |
IsMarketed =cp.IsMarketed , | |
RedeemFlag =cp.RedeemFlag , | |
Reward_id =cp.Reward_id , | |
CreateDate =cp.CreateDate , | |
CreateTime =cp.CreateTime , | |
CreateBy =cp.CreateBy , | |
RedeemDate =cp.RedeemDate , | |
RedeemTime =cp.RedeemTime , | |
RedeemBy =cp.RedeemBy , | |
Member_name =x.Name == null ? "" : x.Name , | |
PointPerCoupon =cb.PointPerCoupon | |
}; | |
return List.ToList(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment