【发布时间】:2010-08-25 15:27:00
【问题描述】:
关于在带有 RIA 服务的presentationModels 上使用接口的问题。
可以通过实现接口的 Ria 服务公开对象?
界面:
public interface TestInterface
{
public int ID {get;set;}
}
我们有一个presentationModel:
public class TestPresentationModel : TestInterface
{
[Key]
public int ID {get;set;}
}
我现在得到一个编译错误: DomainService 'SomeDomainService' 中的实体 'TestInterface' 没有定义键。由 DomainService 操作公开的实体必须至少具有一个标有 KeyAttribute 的公共属性。
我尝试添加 [Key] 属性,但随后出现以下错误: 派生实体类型“TestPresentationModel”必须在根实体“TestInterface”的 KnownTypeAttribute 中声明。
我尝试添加 [KnownTypeAttribute] 属性,但随后出现以下编译错误: 属性“KnownType”在此声明类型上无效。它仅对“类、结构”声明有效。
似乎 Ria 服务试图将接口视为一个实体?我们怎样才能克服这个问题?
问候,
斯蒂芬
【问题讨论】:
标签: c# silverlight interface wcf-ria-services