当前位置: 代码迷 >> ASP.NET >> Lamda表达式实现Left join解决方法
  详细解决方案

Lamda表达式实现Left join解决方法

热度:8049   发布时间:2013-02-25 00:00:00.0
Lamda表达式实现Left join
C# code
var query = User.GroupJoin(Charge, u => u.Account, c => c.Account, (u, c) => new { u, c }).Select(data => new AnalysisPlayer { Account = data.u.Account, PlayerName = data.u.Name, RegTime = data.u.CreateTime ?? DateTime.Now, Points = 此处如何写代码 });public class AnalysisPlayer{        /// <summary>        /// 玩家名称        /// </summary>        public string PlayerName { get; set; }        /// <summary>        /// 玩家账号        /// </summary>        public string Account { get; set; }        /// <summary>        /// 注册时间        /// </summary>        public DateTime RegTime { get; set; }        /// <summary>        /// 充值总数        /// </summary>        public int Points { get; set; }}


------解决方案--------------------------------------------------------
var query = User.GroupJoin(Charge, u => u.Account, c => c.Account, (u, c) => new { u, c })
.Select(data => new AnalysisPlayer { Account = data.u.Account, PlayerName = data.u.Name, 
RegTime = data.u.CreateTime ?? DateTime.Now, Points =data.c==null?0:data.c.Points });
  相关解决方案