用我自己的实体,而不是POCO实体 [英] using my own entities instead of POCO entities

查看:214
本文介绍了用我自己的实体,而不是POCO实体的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我现在用的是实体框架。
我可以使用POCO实体我自己的实体呢?
我可以使用任何的实体,或者有关于实体名称和成员有任何限制?
我怎样才能在数据库字段之间的映射到实体的成员本身,如果实体的成员不具有相同的名称作为域?
更新
我已经有数据库的广告一个大的项目,没有数据访问层的。 我决定将数据访问层和摆脱我所有的存储过程。 现在我面临着如何让以做选择,插入和删除数据库中的数据的问题。我设法了解如何使用POCO对象,但我在转换POCO元素融入我的商业实体获得的麻烦。所以我想知道如果我可以使用波苏斯我自己的实体,而不是为了沟通的分贝。

I am using the entity framework.
Can I use my own entities instead of the POCO entities?
Can I use any entities, or there is any restriction about the entity names and members?
How can I map between the db field to the entity's member itself if the entity's member doesn't have the same name as the field?
UPDATE
I already have the database ad a large project with no data access layer at all. I decided to add data access layer and get rid of my all stored procedures. Right now I am facing the problem of how to get the data from the db in order to do select, insert and delete. I managed to understand how to use POCO objects, but I get trouble in converting the poco elements into my business entities. So I am wondering if I can use my own entities instead of the POCOs in order to communicate the db.

推荐答案

简单地说,如果你已经有了一个大的项目和数据库为好,这怎么可能,你没有开发任何的数据访问层了吗?听起来你做了很多的编码,现在你必须完全unworking应用程序,因为全层缺失。

Simply said, if you already have a large project and database as well, how is it possible that you didn't develop any data access layer yet? Sounds like you did a lot of coding and now you have totally unworking application because whole layer is missing.

我不得不说,你将有真正困难的时候使用EF在这种情况下,因为EF经常指导发展的方式。例如,对于唯一的密钥,硬盘支持枚举(通过黑客),而不是一切都没有支持,可以按照您预期映射。

I have to say that you will have really hard times to use EF in such situation because EF often directs the development its way. For example no support for unique keys, hard support of enums (through the hacks) and not everything can be mapped as you expect.

您也许应该检查的框架更强大的地图功能 - NHibernate的

You should probably check a framework with more powerful mapping features - NHibernate.

这篇关于用我自己的实体,而不是POCO实体的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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