Skip to content

Commit c126585

Browse files
committed
Fixed aspnetboilerplate#1042: LastModificationTime & LastModifierUserId fields update.
1 parent 95ebe97 commit c126585

File tree

2 files changed

+17
-9
lines changed

2 files changed

+17
-9
lines changed

src/Abp.EntityFramework/EntityFramework/Uow/EfUnitOfWork.cs

Lines changed: 16 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -31,9 +31,9 @@ public class EfUnitOfWork : UnitOfWorkBase, ITransientDependency
3131
/// Creates a new <see cref="EfUnitOfWork"/>.
3232
/// </summary>
3333
public EfUnitOfWork(
34-
IIocResolver iocResolver,
35-
IConnectionStringResolver connectionStringResolver,
36-
IDbContextResolver dbContextResolver,
34+
IIocResolver iocResolver,
35+
IConnectionStringResolver connectionStringResolver,
36+
IDbContextResolver dbContextResolver,
3737
IUnitOfWorkDefaultOptions defaultOptions)
3838
: base(connectionStringResolver, defaultOptions)
3939
{
@@ -137,14 +137,18 @@ public virtual TDbContext GetOrCreateDbContext<TDbContext>(MultiTenancySides? mu
137137
connectionStringResolveArgs["DbContextType"] = typeof(TDbContext);
138138
var connectionString = ResolveConnectionString(connectionStringResolveArgs);
139139

140-
var dbContextKey = typeof (TDbContext).FullName + "#" + connectionString;
140+
var dbContextKey = typeof(TDbContext).FullName + "#" + connectionString;
141141

142142
DbContext dbContext;
143143
if (!ActiveDbContexts.TryGetValue(dbContextKey, out dbContext))
144144
{
145145

146146
dbContext = _dbContextResolver.Resolve<TDbContext>(connectionString);
147-
((IObjectContextAdapter)dbContext).ObjectContext.ObjectMaterialized += ObjectContext_ObjectMaterialized;
147+
148+
((IObjectContextAdapter)dbContext).ObjectContext.ObjectMaterialized += (sender, args) =>
149+
{
150+
ObjectContext_ObjectMaterialized(dbContext, args);
151+
};
148152

149153
foreach (var filter in Filters)
150154
{
@@ -197,17 +201,21 @@ protected virtual async Task SaveChangesInDbContextAsync(DbContext dbContext)
197201
{
198202
await dbContext.SaveChangesAsync();
199203
}
200-
204+
201205
protected virtual void Release(DbContext dbContext)
202206
{
203207
dbContext.Dispose();
204208
IocResolver.Release(dbContext);
205209
}
206210

207-
private static void ObjectContext_ObjectMaterialized(object sender, ObjectMaterializedEventArgs e)
211+
private static void ObjectContext_ObjectMaterialized(DbContext dbContext, ObjectMaterializedEventArgs e)
208212
{
209213
var entityType = ObjectContext.GetObjectType(e.Entity.GetType());
210-
DateTimePropertyInfoHelper.NormalizeDatePropertyKinds(e.Entity,entityType);
214+
var previousState = dbContext.Entry(e.Entity).State;
215+
216+
DateTimePropertyInfoHelper.NormalizeDatePropertyKinds(e.Entity, entityType);
217+
218+
dbContext.Entry(e.Entity).State = previousState;
211219
}
212220
}
213221
}

src/Abp/AbpConsts.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ public static class AbpConsts
88
/// <summary>
99
/// Current version of the ABP.
1010
/// </summary>
11-
public const string CurrentVersion = "0.9.1.0";
11+
public const string CurrentVersion = "0.9.1.1";
1212

1313
/// <summary>
1414
/// Localization source name of ASP.NET Boilerplate framework.

0 commit comments

Comments
 (0)