这个在项目中用到了,在网上找了一下才找到,留下来以后自已使用。
List<UniversalInfo> list =new List<UniversalInfo>(); list = (from n in dbEntities.UniversalInfo where n.UniTypeId == unitypeid && n.IsFlag == 1 orderby n.CreateTime descending select new { UniInfoId = n.UniTypeId, UniInfoTitle = n.UniInfoTitle, CreateTime = n.CreateTime }).ToList().Select(a=>new UniversalInfo { UniTypeId = a.UniInfoId, UniInfoTitle = a.UniInfoTitle, CreateTime = a.CreateTime }).ToList(); return list;