RIA DomainService + ActiveRecord

假如想象 提交于 2019-12-08 10:20:27

问题


I tried to use SubSunsonic.ActiveRecord in SL3 project that uses .NET RIA Services. However when I try to return some IQuerable in DomainService class I get an error that the classes generated by Subsonic have a property 'Columns' with an unsupported type. That's what I have

public IEnumerable<SE_NorthWind.SuperEmployee> GetIntegers()
{
  return SE_NorthWind.SuperEmployee.All()
    .Where(emp => emp.Issues > 100)
    .OrderBy(emp => emp.EmployeeID);
}

And this is the error I get

Error   7   Entity 'SE_NorthWind.SuperEmployee' has a property 'Columns' with an unsupported type.  SuperEmployee

Any idea what to do? Don't really wanna use Linq to SQL :)

Thx

P.S. Just tried to LinqTemplates from SubSonic, but this solution I get the error

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

of course SuperEmployee table has a primary key, cause the classes generated by SubSonic can see it

...
Columns.Add(new DatabaseColumn("EmployeeID", this)
            {
                IsPrimaryKey = true,
                DataType = DbType.Int32,
                IsNullable = false,
                AutoIncrement = true,
                IsForeignKey = false,
                MaxLength = 0
            });
...

But RIA objects, they need some attributes. I guess I'll have to go with native Linq To SQL until SubSonic adapts to all this :(


回答1:


To answer the second part of your question.

You need to add the "KeyAttribute" to the PrimaryKey property on the "EmployeeId" property. The attribute is in the "System.ComponentModel.DataAnnotations" namespace.

No up on Sub Sonic 3, but you could change the underlying template to generate this, or change the sub sonic engine and submit it as a patch.

I'm running with SilverLight 3 with RaiServices.

Hope this helps.




回答2:


Can you try removing the [EnableClientAccess()] attribute to see if your project will build?



来源:https://stackoverflow.com/questions/1148553/ria-domainservice-activerecord

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!