OData 服务公开从多个数据源填充的实体
该实体将通过只读 OData 服务 CompanySummary.svc 公开
public class CompanySummary
{
//populated from an Odata service#1 that exposed data from db#1
public int PrimaryId { get; set; } // this will be the DataServiceKey
public int? SecondaryId { get; set; }
public string SomeStringAttribute_1 { get; set; }
//populated from an Odata service#2 that exposed data from db#2
public bool? SomeBoolProperty { get; set; }
//populated from an Odata service#3 that exposed data from db#3
public string SomeStringAttribute_2 { get; set; }
}
那么,填充此混搭实体并通过只读 OData 服务公开它的建议方法是什么?
- 使用 EF 数据提供程序 - 在 db#1 中创建一个模仿此实体的视图。 填充 db#1 中可用的字段,其余字段可以有一些虚拟值。在 edmx 中创建一个使用此数据库视图的实体。然后在实体的 QueryInterceptor 中使用其他 OData 服务来填充字段。
- 使用 Reflection 数据提供程序
- 编写您的数据提供程序
This entity will be exposed via a Read-Only OData service, CompanySummary.svc
public class CompanySummary
{
//populated from an Odata service#1 that exposed data from db#1
public int PrimaryId { get; set; } // this will be the DataServiceKey
public int? SecondaryId { get; set; }
public string SomeStringAttribute_1 { get; set; }
//populated from an Odata service#2 that exposed data from db#2
public bool? SomeBoolProperty { get; set; }
//populated from an Odata service#3 that exposed data from db#3
public string SomeStringAttribute_2 { get; set; }
}
So what is the suggested way to populate this mash-up entity and expose it via a read-only OData service?
- Use the EF data provider - create a view in the db#1 that mimics this entity.
Populate the fields that are available from db#1, and the rest of the fields can have some dummy values. Create an entity in the edmx that uses this DB view. Then in the QueryInterceptor for the entity use the other OData services to populate the fields. - Use the Reflection data provider
- Write your data provider
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论