lamda表达式 中select的问题
var list = OA_UserAnnouncementManager.GetOA_UserAnnouncementByUserID(SCGlobal.User.UserID);
var notices = list.Select(c => c.Announcement);
上面第二行代码,只是通过字段Announcement得到想要的数据,那如果我想通过两个字段:Announcement,IsView得到想要的数据,第二行代码应如何修改,可以实现这样的功能吗?
------解决方案--------------------var notices = list.Select (c=>new {c.Announcement,c.b})
------解决方案--------------------用匿名类或你自定义个类
var notices = list.Select(c => new {Announcement=c.Announcement,IsView=c.IsView});
自定义类
var notices = list.Select(c => new
MyClass {Announcement=c.Announcement,IsView=c.IsView});//
public class MyClass
{
public string Announcement{get;set;}
public bool IsView {get;set;}
}