实体框架和使用WCF服务 [英] Entity Framework and consuming a WCF service

查看:63
本文介绍了实体框架和使用WCF服务的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在获取数据库隐藏在WCF服务后面的数据。
如果我有来自Web服务的自定义对象,是否可以使用Entity Framework?
(无法访问外部数据库,也没有当前的插入/更新/删除逻辑计划)

I'm getting data where the database is hidden behind a WCF service. Is it possible to use Entity Framework in a scenario where I have custom objects coming from a web service? (No access to the external database, and no current plans for insert/update/delete logic)

从一个空的EF模型开始并添加一个实体I在编译时出现此错误:
在EntityContainer中没有为EntitySet和AssociationSet实例指定映射。.

Starting with an empty EF model and adding an entity I get this error on compile: No mapping specified for instances of the EntitySet and AssociationSet in the EntityContainer ..

是否可以通过这种方式创建实体,并填充从对象接收的数据?
(在这种情况下为WCF,但也可以是预定义的模型类/ xml数据)

Is it possible to make an entity this way, and fill it with data received from an object? (In this case a WCF, but could also be a predefined model class/xml data)

如果Web服务撤消了Customer对象,我可以做点什么像这样使用数据集:
制作一个未绑定表并遍历客户属性,将其添加到临时行中,并使用tbl_Customer.Addtbl_CustomerRow(customerRow)将其添加以填充我的视图。

If the web service retured a Customer object I could do something like this with a dataset: Make an unbound table and do a loop through the customer properties adding them to a temp row, add it with tbl_Customer.Addtbl_CustomerRow(customerRow) to get my view filled.

感谢,nakori

推荐答案

实体是数据库条目的对象表示形式(请参阅对象关系)映射; ORM)。在给定Employee和SalesOrder的情况下,数据库中有两个假设表:

Entities are object representation of your DB entries (see Object-Relationnal Mapping; ORMs). Given Employee and SalesOrder, two hypothetical tables in a DB :


Entity:实体是实体类型的实例(例如Employee,SalesOrder),是具有关键字的结构丰富的记录。实体按实体集进行分组。

Entity: entities are instances of Entity Types (e.g. Employee, SalesOrder), which are richly structured records with a key. Entities are grouped in Entity-Sets.

建模数据的概念抽象级别提取: 部分 nofollow noreferrer>《 ADO.NET实体框架概述》 。也许开始使用EF也是不错的选择。

Taken from the Modeling Data at the Conceptual Level of Abstraction: The Entity Data Model section of The ADO.NET Entity Framework Overview. Perhaps it is also a good read to start using the EF.

对于通过WCF进行的通信,它得到了某种支持,以便实体可以完全序列化/反序列化。您可能还想知道,您可以从现有的数据库生成实体,有一个向导以及所有内容。

As for comm through WCF, it is kindof supported, such that entities are fully serializable/deserializable. You may also want to know that you can generate entities from an existing DB, theres a wizard and everything.

这篇关于实体框架和使用WCF服务的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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