日期:2014-05-20 浏览次数:20922 次
public List<T> Graves_QueryPlanView<T>(string areaId) where T:new() { TombDBContext db = new TombDBContext(); var query = from s in db.SubArea join p in db.subAreaPosition on s.Id equals p.FSubArea into temp from p in temp.DefaultIfEmpty() where s.FareaId == areaId select new { s.Id, //区域编号 s.SubName, //区域名称 s.FareaId, //大区编号 posId = (p == null ? 0 : p.pId), //位置编号 posLeft = (p == null ? 0 : p.pLeft), //左距离 }; return query.ToList<T>(); //错误 5 实例参数: 无法从“System.Linq.IQueryable<AnonymousType#1>”转换为“System.Linq.ParallelQuery<T>” F:\projects\TombPrj\TombDAL\GraveService.cs 346 20 TombDAL } private void dd() { List<PlanView> plans = Graves_QueryPlanView<PlanView>("2001"); }
public interface IArea { int Id { get; set; } string SubName { get; set; } int FareaId { get; set; } int ParentId { get; set; } int Left { get; set; } }
------解决方案--------------------
select new T {}