我尝试在使用.NET RIA服务的SL3项目中使用SubSunsonic.ActiveRecord。然而,当我试图在DomainService类中返回一些列时,我得到了一个错误,由Subsonic生成的类有一个带有不支持类型的属性‘IQuerable’。这就是我所拥有的
public IEnumerable<SE_NorthWind.SuperEmployee> GetIntegers()
{
return SE_NorthWind.SuperEmployee.All()
.Where(emp => emp.Issues > 100)
.OrderBy(emp => emp.EmployeeID);
}这是我得到的错误
Error 7 Entity 'SE_NorthWind.SuperEmployee' has a property 'Columns' with an unsupported type. SuperEmployee你知道该怎么做吗?我真的不想使用Linq to SQL :)
Thx
附注:我刚尝试从SubSonic LinqTemplates,但是这个解决方案我得到了错误
Error 4 The entity 'SE_NorthWind.SuperEmployee' does not have a key defined. Entities exposed by DomainService operations must have must have at least one property marked with the KeyAttribute. SuperEmployee当然,SuperEmployee表有一个主键,因为SubSonic生成的类可以看到它
...
Columns.Add(new DatabaseColumn("EmployeeID", this)
{
IsPrimaryKey = true,
DataType = DbType.Int32,
IsNullable = false,
AutoIncrement = true,
IsForeignKey = false,
MaxLength = 0
});
...但是RIA对象,它们需要一些属性。我想我将不得不使用原生Linq to SQL,直到SubSonic适应所有这些:(
发布于 2009-08-04 16:03:03
回答你问题的第二部分。
您需要在"EmployeeId“属性的PrimaryKey属性中添加"KeyAttribute”。该属性位于"System.ComponentModel.DataAnnotations“名称空间中。
在亚音速3上没有,但你可以改变底层模板来生成它,或者改变亚音速引擎并将其作为补丁提交。
我运行的是带有RaiServices的SilverLight 3。
希望这能有所帮助。
发布于 2009-08-21 23:14:30
您是否可以尝试删除EnableClientAccess()属性,以查看您的项目是否可以构建?
https://stackoverflow.com/questions/1148553
复制相似问题