【发布时间】:2011-11-09 14:47:56
【问题描述】:
我有这门课:
public class Detail
{
public Detail() { }
public Detail(Guid Id, DateTime InstanceDate, string Name)
{
CId = Id;
StateInstanceDate = InstanceDate;
StateName = Name;
}
public Guid CId { get; set; }
public DateTime StateInstanceDate { get; set; }
public string StateName { get; set; }
}
这就是我尝试使用 LINQ 访问数据的方式:
public List<Detail> Getinfo()
{
CaseContext cs = new CaseContext();
var query = (from p in cs.table1
join q in cs.table2
on p.StateKey equals q.StateKey
select new Detail
{
p.CId,
p.InstanceDate,
q.StateName
}).ToList<Detail>();
cs.Dispose();
return query;
}
但是我收到了这个错误,
无法使用集合初始化程序初始化类型“Detail”,因为它没有实现“System.Collections.IEnumerable”
有什么帮助吗?
【问题讨论】:
标签: c# .net .net-4.0 ienumerable linq-to-objects