关于使用presentationModel上带有RIA服务接口的问题。通过实现接口的Ria服务公开一个对象
有可能通过Ria Services公开一个对象来实现一个接口?
接口:
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'在此声明类型上无效。它只对'class,struct'声明有效。
Ria服务似乎试图将接口视为实体?我们如何克服这个问题?
问候,
斯特凡
我需要在服务器端和客户端上的接口。我想我碰到了RIA服务的限制。 – Stephane 2010-08-26 06:47:50
它不是一个限制,我们在我们的实现中使用接口,是一个POCO类还是EF生成的? – kmacmahon 2010-09-10 23:21:49
限制是您无法从查询操作中暴露接口。 'public IQueryable GetMyInts()'不支持'public IQueryable GetMyInts()'。 –
2011-06-24 16:47:48