C# 3.0 检索单个实体+;Ria服务

C# 3.0 检索单个实体+;Ria服务,c#-3.0,wcf-ria-services,C# 3.0,Wcf Ria Services,我正在阅读和做一些关于RIA的RnD,作为一个新Silverlight项目的解决方案 我已经阅读了大量文档,并决定使用.NETRIA服务做一个系统的小型模型 我想知道如何从域服务获取单个实体 例如: 我想找个人并填写表格: public Person GetSinglePerson() { return new Person { ID = 4, FirstName = "Cyanide", LastName = "Happiness", Status=3

我正在阅读和做一些关于RIA的RnD,作为一个新Silverlight项目的解决方案

我已经阅读了大量文档,并决定使用.NETRIA服务做一个系统的小型模型

我想知道如何从域服务获取单个实体

例如: 我想找个人并填写表格:

 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类中的属性

比如:


一切似乎都以IEnumerable或CollectionView(如示例中的数据绑定)的形式出现,这对单个实体都没有用处

我想要一个个人条目,为什么我想要一个CollectionView,在其中我不能直接访问属性

我还使用了:

 LoadOperation<Person> oLoadOperation = oDataContext.Load(oDataContext.GetSinglePersonQuery());
LoadOperation-oLoadOperation=oDataContext.Load(oDataContext.GetSinglePersonQuery());

我很快就要放弃这个RIA的想法,转而使用普通的WCF服务,因为在这一阶段它更容易预测和管理。

我想你的类已经用[EnableClientAccess]装饰过了吧

试一试


嘿,刚找到这个,看看吧,我想这就是你想要做的

ctxt.Load(ctxt.GetEmployeeByNumberQuery(“ABC123”)).Completed+=new System.EventHandler(EmployeeLoad_Completed);
已完成作废EmployeeLoad_(对象发送方,System.EventArgs e)
{
Employee myEmployee=(发件人为LoadOperation).Entities.FirstOrDefault();
}

希望ozdeveloper给您指出的我的博文能够回答您的问题。如果没有,请告诉我。
 LoadOperation<Person> oLoadOperation = oDataContext.Load(oDataContext.GetSinglePersonQuery());
<TextBlock Text="{Binding Path=Person.FirstName}"
ctxt.Load(ctxt.GetEmployeeByNumberQuery("ABC123")).Completed += new System.EventHandler(EmployeeLoad_Completed);


void EmployeeLoad_Completed(object sender, System.EventArgs e)
{
    Employee myEmployee = (sender as LoadOperation<Employee>).Entities.FirstOrDefault();
}
        HumanResourceContext context = new HumanResourceContext();

        var addressquery = context.GetAddressesQuery();
        addressquery = addressquery.Where(a => a.AddressId == 1);

        context.Load(addressquery, (op) =>
            {
                Address address = op.Entities.FirstOrDefault();

                MessageBox.Show(address.Street1);
            }, null);