【发布时间】:2011-12-04 15:39:40
【问题描述】:
我创建了一个包含三个类作为属性的类:
public class Feeds
{
public Rentals Rentals { get; set; }
public Agent Agents { get; set; }
public NorthwindService.ServiceReference1.File File { get; set; }
}
我是这样使用它的:
var query = from r in ent.Rentals
join a in ent.Agents on r.ListingAgentID equals a.AgentID
select new Feeds
{
a.AgentID,
a.Alias,
a.Bio,
a.Email,
a.Fax,
r.Firstname,
r.IsStaff,
r.Languages
};
但我收到了错误:
无法使用集合初始化程序初始化类型“NorthwindService.WebForm1.Feeds”,因为它没有实现“System.Collections.IEnumerable”C:\Users\NorthwindService\NorthwindService\WebForm1.aspx.cs
请提出解决方案。
【问题讨论】:
-
您的
select子句没有任何意义。你认为它有什么作用? -
@SLaks 我想从代理中选择一些字段,从租赁中选择一些字段,这就是我创建 Feed 并尝试填充它的原因