RIA 服务实体集不支持“编辑"操作 [英] RIA Services EntitySet does not support 'Edit' operation

查看:22
本文介绍了RIA 服务实体集不支持“编辑"操作的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在 RIA Services (VS2010Beta2) 中迈出第一步,我遇到了这个问题:创建了一个 EF 模型(无 POCO)、其上的通用存储库和 RIA 服务(托管在 ASP.NET MVC 应用程序中)并尝试从 ASP.NET MVC 应用程序中获取数据:运行良好.下一步:Silverlight 客户端.获得对 RIAService 的引用(通过其上下文),查询存储库的所有记录并将它们也放入 SL 应用程序(使用此代码示例):

Making my first steps in RIA Services (VS2010Beta2) and i encountered this problem: created an EF Model (no POCOs), generic repository on top of it and a RIA Service(hosted in an ASP.NET MVC application) and tried to get data from within the ASP.NET MVC application: worked well. Next step: Silverlight client. Got a reference to the RIAService (through its context), queried for all the records of the repository and got them into the SL application as well (using this code sample):

private ObservableCollection<Culture> _cultures = new ObservableCollection<Culture>();
public ObservableCollection<Culture> cultures
{
  get { return _cultures; }
  set
  {
    _cultures = value;
    RaisePropertyChanged("cultures");
  }
}

....

//Get cultures            
EntityQuery<Culture> queryCultures = from cu in dsCtxt.GetAllCulturesQuery()
                                             select cu;
loCultures = dsCtxt.Load(queryCultures);
loCultures.Completed += new EventHandler(lo_Completed);

....

void loAnyCulture_Completed(object sender, EventArgs e)
{
  ObservableCollection<Culture> temp= 
  new ObservableCollection<Culture>loAnyCulture.Entities);
                AnyCulture = temp[0];
}

问题是这样的:每当我尝试编辑记录的某些数据(在本例中为第一条记录)时,我都会收到此错误:此文化"类型的实体集不支持编辑"操作.

The problem is this: whenever i try to edit some data of a record (in this example the first record) i get this error: This EntitySet of type 'Culture' does not support the 'Edit' operation.

我认为我做了一些奇怪的事情,并试图创建一个类型为 Culture 的对象并为其分配一个值:它运行良好!

I thought that i did something weird and tried to create an object of type Culture and assign a value to it: it worked well!

我错过了什么?我必须声明一个实体集吗?我必须标记它吗?我必须……什么?

What am i missing? Do i have to declare an EntitySet? Do i have to mark it? Do i have to...what?

提前致谢

推荐答案

事实证明,在 DomainService 类中,必须实现(或至少将占位符方法"标记为编辑"、删除")... 例如

It turns out that in the DomainService class one has to implement (or at least to mark "placeholder methods") as "Edit", "Delete",... eg

[Delete]
public void DeleteCulture(Culture currentCulture)
{
   throw new NotImplementedException("UpdateCulture not Implemented yet");
}
[Insert]
public void InsertCulture(Culture newCulture)
{
   throw new NotImplementedException("InsertCulture not Implemented yet");
}

通过这种方式,OrganizationDomainContextEntityContainer 类创建一个带有参数 EntitySetOperations.All 的 EntitySet(意味着所有 CUD 操作都可用).

This way the OrganizationDomainContextEntityContainer class creates an EntitySet with parameter EntitySetOperations.All (meaning that all the CUD operations are available).

希望对未来的人有用!

这篇关于RIA 服务实体集不支持“编辑"操作的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆