public virtual void Initialize(AbpEfDbContextInitializationContext initializationContext)
        {
            var uowOptions = initializationContext.UnitOfWork.Options;

            if (uowOptions.Timeout.HasValue && !Database.CommandTimeout.HasValue)
            {
                Database.CommandTimeout = uowOptions.Timeout.Value.TotalSeconds.To <int>();
            }

            if (Clock.SupportsMultipleTimezone)
            {
                ((IObjectContextAdapter)this).ObjectContext.ObjectMaterialized += (sender, args) =>
                {
                    var entityType = ObjectContext.GetObjectType(args.Entity.GetType());

                    Configuration.AutoDetectChangesEnabled = false;
                    var previousState = Entry(args.Entity).State;

                    DateTimePropertyInfoHelper.NormalizeDatePropertyKinds(args.Entity, entityType);

                    Entry(args.Entity).State = previousState;
                    Configuration.AutoDetectChangesEnabled = true;
                };
            }
        }
示例#2
0
        private static void ObjectContext_ObjectMaterialized(DbContext dbContext, ObjectMaterializedEventArgs e)
        {
            var entityType    = ObjectContext.GetObjectType(e.Entity.GetType());
            var previousState = dbContext.Entry(e.Entity).State;

            DateTimePropertyInfoHelper.NormalizeDatePropertyKinds(e.Entity, entityType);

            dbContext.Entry(e.Entity).State = previousState;
        }
示例#3
0
        private static void ObjectContext_ObjectMaterialized(DbContext dbContext, ObjectMaterializedEventArgs e)
        {
            var entityType = ObjectContext.GetObjectType(e.Entity.GetType());

            dbContext.Configuration.AutoDetectChangesEnabled = false;

            DateTimePropertyInfoHelper.NormalizeDatePropertyKinds(e.Entity, entityType);

            dbContext.Entry(e.Entity).State = EntityState.Unchanged;
            dbContext.Configuration.AutoDetectChangesEnabled = true;
        }
示例#4
0
        private void ObjectContext_ObjectMaterialized([NotNull] DbContext dbContext, ObjectMaterializedEventArgs e)
        {
            Type entityType = ObjectContext.GetObjectType(e.Entity.GetType());

            dbContext.Configuration.AutoDetectChangesEnabled = false;
            EntityState previousState = dbContext.Entry(e.Entity).State;

            DateTimePropertyInfoHelper.NormalizeDatePropertyKinds(e.Entity, entityType);

            dbContext.Entry(e.Entity).State = previousState;
            dbContext.Configuration.AutoDetectChangesEnabled = true;
        }
        private static void ObjectContext_ObjectMaterialized(object sender, ObjectMaterializedEventArgs e)
        {
            var entityType = ObjectContext.GetObjectType(e.Entity.GetType());

            DateTimePropertyInfoHelper.NormalizeDatePropertyKinds(e.Entity, entityType);
        }