zoukankan      html  css  js  c++  java
  • EntitySpaces2009支持事务

    EntitySpaces2009支持事件。

    Transactions

    You do not need to wrap saves on a single collection in a transaction. EntitySpaces does this for you, even if you have multiple inserts, updates, and deletes. Use transactions if you are saving two or more objects that need to rollback as a set in the event of a failure. EntitySpaces has two transaction models. esTransactionScope works with all supported databases. Set providerClass="DataProvider" in your app.config. TransactionScope uses the new .NET 2.0 TransactionScope class for databases that support it. Set providerClass="DataProviderEnterprise" in your app.config.

    e.g.

    OrdersCollection ordersCollection = new OrdersCollection();  
    Orders ordersEntity = new Orders();  
    OrderDetailsCollection orderDetailsCollection = new OrderDetailsCollection();  
    OrderDetails orderDetailsEntity = new OrderDetails();  
       
    ordersEntity = ordersCollection.AddNew();  
    ordersEntity.str.CustomerId = "3";  
       
    orderDetailsEntity = orderDetailsCollection.AddNew();   
      
    orderDetailsEntity.str.ProductId = "147";  
    orderDetailsEntity = orderDetailsCollection.AddNew();  
    orderDetailsEntity.OrderId = orderId;  
    orderDetailsEntity.str.ProductId = "255";  
       
    using(esTransactionScope scope = new esTransactionScope())  
    {  
             ordersCollection.Save();   

             //设置子对象的外键字段的值必须在父对象的主键值得到后才能设置,不然此值为null

             orderDetailsEntity.OrderId = ordersEntity.Id.Value;
             orderDetailsCollection.Save();  
             scope.Complete();  
    }

  • 相关阅读:
    服务器监控利器
    退出率与跳出率
    PHP替换中文字符
    编码问题导致样式显示在IE中不正常
    ADO.NET
    生成n*n蛇形矩阵的算法
    数组地址问题
    数组的首地址,数组名取地址,地址的强制转换为int
    教程:VS2010 之TFS入门指南
    10进制与17进制的转化(代码已测试)
  • 原文地址:https://www.cnblogs.com/Rising/p/1660359.html
Copyright © 2011-2022 走看看