gpt4 book ai didi

wcf-ria-services - RIA Services EntitySet 不支持 'Edit' 操作

转载 作者:行者123 更新时间:2023-12-03 12:29:18 26 4
gpt4 key购买 nike

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

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];
}

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

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

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

提前致谢

最佳答案

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

[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");
}

这样,Org​​anizationDomainContextEntityContainer 类创建一个带有参数 EntitySetOperations.All 的 EntitySet(意味着所有 CUD 操作都可用)。

希望它对将来的某人有用!

关于wcf-ria-services - RIA Services EntitySet 不支持 'Edit' 操作,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/2445634/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com