RIA 域服务 + 活动记录

发布于 2024-07-29 06:23:56 字数 1362 浏览 4 评论 0原文

我尝试在使用 .NET RIA 服务的 SL3 项目中使用 SubSunsonic.ActiveRecord。 但是,当我尝试在 DomainService 类中返回一些 IQuerable 时,我收到一条错误,表明 Subsonic 生成的类具有类型不受支持的属性“Columns”。 这就是我所得到的

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

P.S. 刚刚尝试使用 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 适应这一切:(

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 :(

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

迷爱 2024-08-05 06:23:56

回答你问题的第二部分。

您需要将“KeyAttribute”添加到“EmployeeId”属性的 PrimaryKey 属性中。
该属性位于“System.ComponentModel.DataAnnotations”命名空间中。

Sub Sonic 3 没有,但您可以更改底层模板来生成它,或者更改次音速引擎并将其作为补丁提交。

我正在使用 SilverLight 3 和 RaiServices 运行。

希望这可以帮助。

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.

当爱已成负担 2024-08-05 06:23:56

您可以尝试删除 [EnableClientAccess()] 属性来查看您的项目是否可以构建吗?

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

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文