检索单个实体+里亚服务
我正在阅读并做一些有关 RIA 的 RnD,作为新 Silverlight 项目的解决方案。
我阅读了大量文档,并决定使用 .Net RIA 服务制作一个系统的小型模型。
我想知道如何从域服务获取单个实体?
例子: 我想找人并填写表格:
public Person GetSinglePerson()
{
return new Person { ID = 4, FirstName = "Cyanide", LastName = "Happiness", Status=3 };
} 假设我使用 DomainDataSource:
<riaControls:DomainDataSource x:Name="source2" QueryName="GetSinglePersonQuery" AutoLoad="True">
<riaControls:DomainDataSource.DomainContext>
<web:DataContext/>
</riaControls:DomainDataSource.DomainContext>
</riaControls:DomainDataSource>
这仅返回 EntityCollectionView?例如,如何将表单绑定到 Person 类中的属性?
喜欢:
<TextBox Text="{Binding FirstName, ElementName=source2}"/>
一切似乎都以 IEnumerable 或 CollectionViews(如示例中的 DATA 绑定)的形式返回,这对于单个实体没有用处。
我想要一个单人条目,为什么我想要一个无法直接访问属性的 CollectionView。
我还使用过:
LoadOperation<Person> oLoadOperation = oDataContext.Load(oDataContext.GetSinglePersonQuery());
我非常接近放弃这个 RIA 想法,而只是使用普通的 WCF 服务,因为它在现阶段更可预测和可管理。
I am reading and doing some RnD on RIA as a solution for a new Silverlight project.
I have read alot of the documentation and decided to do a small mockup of a system using .Net RIA Services.
I want to know how to get a Single Entity from the Domain Service?
example:
I want to get a person and populate a form:
public Person GetSinglePerson()
{
return new Person { ID = 4, FirstName = "Cyanide", LastName = "Happiness", Status=3 };
}
Say I use the the DomainDataSource:
<riaControls:DomainDataSource x:Name="source2" QueryName="GetSinglePersonQuery" AutoLoad="True">
<riaControls:DomainDataSource.DomainContext>
<web:DataContext/>
</riaControls:DomainDataSource.DomainContext>
</riaControls:DomainDataSource>
This only returns a EntityCollectionView? How do I bind for example in a form to properties that are in the Person Class?
Like:
<TextBox Text="{Binding FirstName, ElementName=source2}"/>
Everything seems to come back as IEnumerable or as CollectionViews (like the DATA binding in the samples) which aren't useful for a single entity.
I want a single persons entry, why do I want a CollectionView in which I cannot access properties directly.
I have also use the:
LoadOperation<Person> oLoadOperation = oDataContext.Load(oDataContext.GetSinglePersonQuery());
I am very close to giving up on this RIA idea and just going with a normal WCF service as it is more predictable and manageable at this stage.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(4)
嘿刚刚发现这个检查一下我认为这就是你想做的
http://jeffhandley.com/archive/2009/11/10/domaindatasource-single-record.aspx
hey just found this check it out I think this is what you want to do
http://jeffhandley.com/archive/2009/11/10/domaindatasource-single-record.aspx
我想你的班级用 [EnableClientAccess] 装饰?
尝试
I presume you have your class decorated with [EnableClientAccess] ?
try