zoukankan      html  css  js  c++  java
  • Entity Framework Tutorial Basics(20):Persistence in Entity Framework

    Persistence in Entity Framework

    There are two scenarios when persisting an entity using EntityFramework, connected and disconnected scenarios.

    Connected Scenario: This is when an entity is retrieved from the database and persist is used in the same context. Context object doesn't destroy between entity retrieval and persistence of entities.

    Entity Framework tutorial 4.3 dbcontext

    Disconnected Scenario: Disconnected scenario is when an entity is retrieved from the database and the changed entities are submitted using the different objects in the context. The following example illustrates disconnected scenario:

    Entity Framework tutorial 4.3 dbcontext

    As per the above scenario, Context1 is used for read operation and then Context1 is destroyed. Once entities change, the application submits entities using Context2 - a different context object.

    Disconnected scenario is complex because the new context doesn't know anything about the modified entity so you will have to instruct the context of what has changed in the entity. In the figure below, the application retrieves an entity graph using Context 1 and then the application performs some CUD (Create, Update, Delete) operations on it and finally, it saves the entity graph using Context 2. Context 2 doesn't know what operation has been performed on the entity graph in this scenario.

    Learn how to do the CRUD operation in the connected scenario in the next section.

  • 相关阅读:
    Android ViewPager用法小结
    HDU1212 Big Number 【同余定理】
    1051. Pop Sequence (25)
    FFmpeg源码结构图
    oracle访问不同用户的表不添加用户名前缀
    window7开启Administrator账户
    Window下对nodejs多版本管理GNVM
    基于Centos7.5搭建Docker环境
    grep与孪生兄弟egrep差异
    Linux编译步骤概述
  • 原文地址:https://www.cnblogs.com/purplefox2008/p/5649051.html
Copyright © 2011-2022 走看看