实体框架POCO对象

编程入门 行业动态 更新时间:2024-10-24 16:22:07
本文介绍了实体框架POCO对象的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述 我很难理解实体框架和POCO对象。这是我正在努力实现的。

1)通过让我的业务层使用我的DAL的界面,将DAL与业务层分开。可能使用Unity来创建我的上下文。

2)在我的DAL中使用Entity Framework。

我有一个域模型,其中包含我的业务层中的对象。我还有一个数据库充满了表,并不代表我的域模型。我使用ADO.NET POCO Generator扩展设置Entity Framework并生成POCO对象。这给了我一个数据库中每个表的对象。现在我想要能够说 context.GetAll< User>(); 并让它返回一个我的User对象列表。 User对象在我的业务层。这是可能吗?

这是否有意义,或者我完全失败了,应该重新开始?我猜想我需要使用存储库模式来实现这一点,但我不确定。

任何人都可以帮忙?

解决方案

4在n层架构中的复杂性:

  • devtalk.dk/2009/06/09/Entity+Framework+40 + Beta + 1 + POCO + ObjectSet + Repository + And + UnitOfWork.aspx
  • blog.keithpatton/2009/05/30 /Entity+Framework+POCO+Repository+Using+Visual+Studio+2010+Net+40+Beta+1.aspx
  • www.simonsegal/blog/2010/01/ 11 / entity-framework-repositories-fetching-strategies-specification-and-mapping-using-nfetchspec-for-role-driven-development-part-1-4
  • I'm struggling with understanding Entity Framework and POCO objects. Here's what I'm trying to achieve.

    1) Separate the DAL from the Business Layer by having my business layer use an interface to my DAL. Maybe use Unity to create my context.

    2) Use Entity Framework inside my DAL.

    I have a Domain model with objects that reside in my business layer. I also have a database full of tables that doesn't really represent my domain model. I setup Entity Framework and generated POCO objects by using the ADO.NET POCO Generator extension. This gave me an object for each table in my database. Now I want to be able to say context.GetAll<User>(); and have it return a list of my User objects. The User object is in my business layer. Is that possible?

    Does that make sense or am I totally off and should start over? I'm guessing I need to use the repository pattern to achieve this, but I'm not sure.

    Can anyone help?

    解决方案

    Examples how to put entity framework 4 in n-tier arhitecture in order of complexity:

  • devtalk.dk/2009/06/09/Entity+Framework+40+Beta+1+POCO+ObjectSet+Repository+And+UnitOfWork.aspx
  • blog.keithpatton/2009/05/30/Entity+Framework+POCO+Repository+Using+Visual+Studio+2010+Net+40+Beta+1.aspx
  • danielwertheim.files.wordpress/2009/12/putting-entity-framework-4-to-use-in-a-business-architecture-v2.pdf
  • www.simonsegal/blog/2010/01/11/entity-framework-repositories-fetching-strategies-specification-and-mapping-using-nfetchspec-for-role-driven-development-parts-1-4
  • 更多推荐

    实体框架POCO对象

    本文发布于:2023-07-27 11:53:01,感谢您对本站的认可!
    本文链接:https://www.elefans.com/category/jswz/34/1222309.html
    版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
    本文标签:实体   框架   对象   POCO

    发布评论

    评论列表 (有 0 条评论)
    草根站长

    >www.elefans.com

    编程频道|电子爱好者 - 技术资讯及电子产品介绍!