RIA 服务 EntitySet 不支持“编辑”;手术
在 RIA Services (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 吗?我必须标记它吗?我必须……什么吗?
提前致谢
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.
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?
Thanks in advance
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
事实证明,在 DomainService 类中,必须实现(或至少将“占位符方法”标记为“编辑”、“删除”,...例如,
OrganizationDomainContextEntityContainer 类通过这种方式创建一个带有参数 EntitySetOperations.All 的 EntitySet(意味着所有 CUD 操作都可用)。
希望它对将来的人有用!
It turns out that in the DomainService class one has to implement (or at least to mark "placeholder methods") as "Edit", "Delete",... eg
This way the OrganizationDomainContextEntityContainer class creates an EntitySet with parameter EntitySetOperations.All (meaning that all the CUD operations are available).
Hope it's useful for someone in the future!