Lamda常见用法
# List的Lamda查询方法
var dr = tchmaterials.Select(o => { return (o.f_edition1 == item.f_edition1 && o.f_class == item.f_class) ? o : null; }).ToList<Tchmaterial>();
# 查询后按时间排序该方法待验证
topicReplyList.Sort(delegate(ETopicReplyInfo m, ETopicReplyInfo n) { return m.P_FloorDesc.CompareTo(n.P_FloorDesc); });
# 读取匿名对象中的属性
var status= values.GetType().GetProperty("result").GetValue(values, null);
# Lamda中delegate的用法
Organizations orgOne = organList.Find(delegate(Organizations org) { return (org.P_UserRoleType == 1); });
# GroupBy 用法
List<E2NationalAward> userLottrys = Dal2NationalAward.GetInstance().GetUserLotteryResult(mfgId);
if (userLottrys != null && userLottrys.Count > 0)
{
var result = userLottrys.GroupBy(o => o.PrizesType).Select(p => (new UserAward()
{
UserId = mfgId,
AwardId = p.Key,
AwardName = GetName(p.Key),
Count = p.Count(),
Status = p.Key.Equals(1) ? "待发货" : "已入账单"
})).ToList();
return result;
}
# 线程池用法
ReqestParam param = new ReqestParam();
param.Id = 1;
param.Name = "wqcb";
param.Name1 = "123";
param.Name2 = "rtyu";
for (int i = 0; i < 10; i++){
param.Id = i;
ThreadPool.QueueUserWorkItem(new WaitCallback(ThreadInvoke), param);
}
public void ThreadInvoke(object obj){
ReqestParam p=obj as ReqestParam;
}