相关疑难解决方法(0)

WCF数据服务(OData),具有继承限制的查询?

项目:使用内部EF4 CTP5代码优先方法的WCF数据服务.

我配置了具有继承(TPH)的实体.查看有关此主题的上一个问题:

以前关于多个实体的问题 - 同一个表

映射效果很好,EF4上的单元测试确认查询运行顺利.

我的实体看起来像这样:

  • ContactBase(摘要)
  • Customer(继承自ContactBase),此实体还具有针对其他实体的多个Navigation属性
  • 资源(继承自ContactBase)

我已配置了一个鉴别器,因此Customer和Resource都映射到同一个表.同样,在Ef4的观点上,每个事情都可以正常工作(单元测试所有绿色!)

但是,当通过WCF数据服务公开这个DBContext时,我得到: - CustomerBases设置暴露(客户和资源集似乎是隐藏的,是设计吗?) - 当我在客户上查询Odata时,我收到此错误:

Navigation Properties are not supported on derived entity types. Entity Set 'ContactBases' has a instance of type 'CodeFirstNamespace.Customer', which is an derived entity type and has navigation properties. Please remove all the navigation properties from type 'CodeFirstNamespace.Customer'. 
Run Code Online (Sandbox Code Playgroud)

堆栈跟踪:

at System.Data.Services.Serializers.SyndicationSerializer.WriteObjectProperties(IExpandedResult expanded, Object customObject, ResourceType resourceType, Uri absoluteUri, String relativeUri, SyndicationItem item, DictionaryContent content, EpmSourcePathSegment currentSourceRoot)
at System.Data.Services.Serializers.SyndicationSerializer.WriteEntryElement(IExpandedResult expanded, Object element, ResourceType expectedType, Uri …
Run Code Online (Sandbox Code Playgroud)

inheritance entity-framework entity-framework-4 wcf-data-services odata

6
推荐指数
1
解决办法
2511
查看次数