1- using System . Collections . Generic ;
1+ using System ;
2+ using System . Collections . Generic ;
23using System . Data ;
34using System . Data . Common ;
45using System . Data . Entity ;
@@ -39,7 +40,6 @@ IList<TEntity> ExecuteStoredProcedureList<TEntity>(string commandText, params ob
3940 /// <summary>Executes sql by using SQL-Server Management Objects which supports GO statements.</summary>
4041 int ExecuteSqlThroughSmo ( string sql ) ;
4142
42- // codehint: sm-add (required for UoW implementation)
4343 string Alias { get ; }
4444
4545 // increasing performance on bulk operations
@@ -59,6 +59,12 @@ IList<TEntity> ExecuteStoredProcedureList<TEntity>(string commandText, params ob
5959 /// </remarks>
6060 bool ForceNoTracking { get ; set ; }
6161
62+ /// <summary>
63+ /// Gets or sets a value indicating whether database write operations
64+ /// originating from repositories should be committed immediately.
65+ /// </summary>
66+ bool AutoCommitEnabled { get ; set ; }
67+
6268 /// <summary>
6369 /// Gets a list of modified properties for the specified entity
6470 /// </summary>
@@ -86,12 +92,6 @@ IList<TEntity> ExecuteStoredProcedureList<TEntity>(string commandText, params ob
8692 /// <param name="entity">The entity instance to detach</param>
8793 void DetachEntity < TEntity > ( TEntity entity ) where TEntity : BaseEntity , new ( ) ;
8894
89- /// <summary>
90- /// Detaches an entity from the current object context
91- /// </summary>
92- /// <param name="entity">The entity instance to detach</param>
93- void Detach ( object entity ) ;
94-
9595 /// <summary>
9696 /// Detaches all entities from the current object context
9797 /// </summary>
@@ -104,15 +104,15 @@ IList<TEntity> ExecuteStoredProcedureList<TEntity>(string commandText, params ob
104104 /// <typeparam name="TEntity">Type of entity</typeparam>
105105 /// <param name="entity">The entity instance</param>
106106 /// <param name="newState">The new state</param>
107- void ChangeState < TEntity > ( TEntity entity , System . Data . Entity . EntityState newState ) ;
107+ void ChangeState < TEntity > ( TEntity entity , System . Data . Entity . EntityState newState ) where TEntity : BaseEntity , new ( ) ;
108108
109109 /// <summary>
110- /// Changes the object state to unchanged
110+ /// Reloads the entity from the database overwriting any property values with values from the database.
111+ /// The entity will be in the Unchanged state after calling this method.
111112 /// </summary>
112113 /// <typeparam name="TEntity">Type of entity</typeparam>
113114 /// <param name="entity">The entity instance</param>
114- /// <returns>true on success, false on failure</returns>
115- bool SetToUnchanged < TEntity > ( TEntity entity ) ;
115+ void ReloadEntity < TEntity > ( TEntity entity ) where TEntity : BaseEntity , new ( ) ;
116116
117117 /// <summary>
118118 /// Begins a transaction on the underlying store connection using the specified isolation level
@@ -127,4 +127,29 @@ IList<TEntity> ExecuteStoredProcedureList<TEntity>(string commandText, params ob
127127 /// <param name="transaction">the external transaction</param>
128128 void UseTransaction ( DbTransaction transaction ) ;
129129 }
130+
131+ public static class IDbContextExtensions
132+ {
133+
134+ /// <summary>
135+ /// Changes the object state to unchanged
136+ /// </summary>
137+ /// <typeparam name="TEntity">Type of entity</typeparam>
138+ /// <param name="entity">The entity instance</param>
139+ /// <returns>true on success, false on failure</returns>
140+ public static bool SetToUnchanged < TEntity > ( this IDbContext ctx , TEntity entity ) where TEntity : BaseEntity , new ( )
141+ {
142+ try
143+ {
144+ ctx . ChangeState < TEntity > ( entity , System . Data . Entity . EntityState . Unchanged ) ;
145+ return true ;
146+ }
147+ catch ( Exception ex )
148+ {
149+ ex . Dump ( ) ;
150+ return false ;
151+ }
152+ }
153+
154+ }
130155}
0 commit comments