Wednesday, November 30, 2011

TRANSACTION implementation in LINQ

LINQ is become one of most popular. But Based on our business logic we need to Use Transaction in LINQ.
LINQ Transaction is much more smart. You do not need to rollback. If it fail to complete any query it automatically rollback.

To use transaction You have to add a .NET dll name  "System.Transaction" in reference of your application.

.

Now in your DataAccess Layer you can use like

  public void UpdateSaleDetailsTable(ESalesReturn aSalesReturn)  
     {  
       using(System.Transactions.TransactionScope scope = new System.Transactions.TransactionScope(System.Transactions.TransactionScopeOption.Required))  
       {  
         UpdateSaleDetailsTableData(aSalesReturn);  
         UpdateSaleTable(aSalesReturn);  
         UpdateCurrentProductTable(aSalesReturn);  
         InsertIntoSalesReturnTable(aSalesReturn);  
         scope.Complete();  
       }  
     }  

SQL Get all Index create script from Database

To get all script from database as a create new index into another database you can use the following --Get all Index Script SELECT...