linq问题

mingcsharp 2015-01-25 10:32:48
public List<MaterialModel> GetDataRows(string key, DateTime dtleft, DateTime dtright)
{
var linq = from c in dbContext.MaterialEntry
join d in dbContext.MaterialEntryItem on c.SheetId equals d.SheetId into result1
from ed in result1.DefaultIfEmpty()
join e in dbContext.WareRoom on c.WareRoomId equals e.WareRoomId into result2
from ee in result2.DefaultIfEmpty()
join f in dbContext.Supplier on c.SupplierId equals f.SupplierId into result3
from ff in result3.DefaultIfEmpty()
join g in dbContext.Employee on c.WareRoomMan equals g.EmployeeId into result4
from gg in result4.DefaultIfEmpty()
where c.SheetId.Contains(key) && c.CreateTime >= dtleft && c.CreateTime <= dtright
orderby c.SheetId descending
select new MaterialModel
{//这里报错说
c.SheetId,
ee.WareRoomName,
ff.SupplierName,
gg.EmployeeName,
c.CreateTime,
ed.MaterialsName,
ed.UnitPack,
ed.QtyPack,
ed.Qty,
ed.Price,
ed.Total,
ed.TotalMoney,
};
dbContext.Database.Log = new Action<string>(q => LogHelper.WriteLog("sql", q));
return linq.ToList<MaterialModel>();
}


Error 1 Cannot initialize type 'Surpass.Model.MaterialModel' with a collection initializer because it does not implement 'System.Collections.IEnumerable' G:\Project\VS2010\Surpass12\Surpass.DataAccess\MaterialDataAccess\MaterialEntryDAL.cs 174 24 Surpass.DataAccess
...全文
63 回复 打赏 收藏 转发到动态 举报
写回复
用AI写文章
回复
切换为时间正序
请发表友善的回复…
发表回复

110,534

社区成员

发帖
与我相关
我的任务
社区描述
.NET技术 C#
社区管理员
  • C#
  • Web++
  • by_封爱
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告

让您成为最强悍的C#开发者

试试用AI创作助手写篇文章吧