/// <summary> /// /// </summary> public MultiEfRepository() { Type t = typeof(T); lock (t) { Service service = null; if (s_EntityKeyedServices.ContainsKey(t)) { service = s_EntityKeyedServices[t]; } else { var contextKeyAttribute = t.GetCustomAttribute <EntityContextKeyAttribute>(); if (contextKeyAttribute == null || contextKeyAttribute.ContextKey.IsEmpty()) { service = new TypedService(t); } else { service = new KeyedService(contextKeyAttribute.ContextKey, t); } s_EntityKeyedServices.Add(t, service); } _context = EngineContext.Current.ContainerManager.ResolveService <IChenyuanDBContext>(service); } }
/// <summary> /// /// </summary> /// <param name="logAction"></param> /// <param name="entity"></param> /// <param name="dbContext"></param> /// <param name="logActionName"></param> public EntityLogInfoImpl(EntityLogActionType logAction, TEntity entity, IChenyuanDBContext dbContext = null, string logActionName = null) : base(logAction, entity, logActionName) { _dbContext = dbContext; LogInfo = EntityLogPropertyInfos(entity); if (logAction == EntityLogActionType.Update) { var entry = (_dbContext as DbContext).Entry(entity); this.OriginalValues = entry.OriginalValues.Clone(); } }
/// <summary> /// /// </summary> /// <param name="context"></param> public EfRepository(IChenyuanDBContext context) { _context = context; }