private void AddForDelete(T dto, DataScope <TSession, TMetadata> scope)
        {
            var entity        = GetLLBLGenEntity(dto);
            var entityManager = GetEntityManager(entity, scope);

            entityManager.DeleteEntity(entity);
        }
Ejemplo n.º 2
0
        public TDataManager GetDataManager <TDataManager>(DataScope <TSessionInfo, TMetadata> scope)
            where TDataManager : class, IDataManager <TSessionInfo, TMetadata>, new()
        {
            var output = new TDataManager();

            OnAcquiredDataManager(output, scope);
            return(output);
        }
Ejemplo n.º 3
0
        public TEntityManager GetEntityManager <TEntityManager>(DataScope <TSessionInfo, TMetadata> scope)
            where TEntityManager : class, IEntityManager <TSessionInfo, TMetadata>, new()
        {
            var args   = base.BuildDefaultArgs();
            var output = base.CreateInstance <TEntityManager>(args);

            OnAcquiredDataManager(output, scope);
            OnAcquiredEntityManager(output, scope);
            return(output);
        }
        public void Route(PersistContainer <T> work, DataScope <TSession, TMetadata> scope)
        {
            work.ToCreate.ForEach(dto =>
            {
                AddForSave(dto, scope);
            });

            work.ToUpdate.ForEach(dto =>
            {
                AddForSave(dto, scope);
            });

            work.ToDelete.ForEach(dto =>
            {
                AddForDelete(dto, scope);
            });
        }
Ejemplo n.º 5
0
        public DataScope <TSessionInfo, TMetadata> GetDataScope(IDataAccessAdapter adapter, TSessionInfo sessionInfo, FunctionMappingStore functionMappings, UnitOfWork2 uow)
        {
            TMetadata md = new TMetadata();

            ReflectionHelper.SetPropertyValue(md, "AdapterToUse", adapter);

            if (functionMappings != null)
            {
                ReflectionHelper.SetPropertyValue(md, "CustomFunctionMappings", functionMappings);
            }

            var output = new DataScope <TSessionInfo, TMetadata>()
            {
                Adapter     = adapter,
                Metadata    = md,
                UnitOfWork  = uow,
                SessionInfo = sessionInfo
            };

            return(output);
        }
Ejemplo n.º 6
0
        public IEntityManager <TSessionInfo, TEntity, TMetadata> GetManagerForEntity <TEntity>(DataScope <TSessionInfo, TMetadata> scope)
            where TEntity : EntityBase2, new()
        {
            var args = base.BuildDefaultArgs();

            args.EntityType = typeof(TEntity);
            var output = base.CreateInstance <IEntityManager <TSessionInfo, TEntity, TMetadata> >(args);

            OnAcquiredDataManager(output, scope);
            OnAcquiredEntityManager(output, scope);
            return(output);
        }
Ejemplo n.º 7
0
        public IEntityManager <TSessionInfo, TMetadata> GetManagerForEntity(EntityBase2 entity, DataScope <TSessionInfo, TMetadata> scope)
        {
            var type = entity.GetType();
            var mi   = new RelayReflectedMethod <EntityManagerSource <TSessionInfo, TMetadata>, IEntityManager <TSessionInfo, TMetadata>, DataScope <TSessionInfo, TMetadata> >(
                "GetManagerForEntity", this, System.Reflection.BindingFlags.Default, new Type[] { type }, null, null);

            return(mi.Invoke(scope));
        }
Ejemplo n.º 8
0
 protected virtual void OnAcquiredDataManager(IDataManager <TSessionInfo, TMetadata> manager, DataScope <TSessionInfo, TMetadata> scope)
 {
     manager.Scope  = scope;
     manager.Source = this;
 }
Ejemplo n.º 9
0
 protected virtual void OnAcquiredEntityManager(IEntityManager <TSessionInfo, TMetadata> manager, DataScope <TSessionInfo, TMetadata> scope)
 {
 }
 protected IEntityManager <TSession, TMetaData> GetManagerForEntity <TEntity>(DataScope <TSession, TMetaData> scope)
     where TEntity : EntityBase2, IEntity2, new()
 {
     return(Source.GetManagerForEntity <TEntity>(scope));
 }
 protected TManager GetManager <TManager>(DataScope <TSession, TMetaData> scope)
     where TManager : class, IDataManager <TSession, TMetaData>, new()
 {
     return(Source.GetDataManager <TManager>(scope));
 }
        private static void PerformActionsOnScope(IAdapterService adapterService, Action <DataScope <TSession, TMetaData> > toPerform, DataScope <TSession, TMetaData> scope)
        {
            var before = adapterService.GetBeforeAction();

            if (before != null)
            {
                before(scope.Adapter);
            }

            toPerform(scope);

            var after = adapterService.GetAfterAction();

            if (after != null)
            {
                after(scope.Adapter);
            }
        }
 protected virtual IEntityManager <TSession, TMetadata> GetEntityManager(EntityBase2 entity, DataScope <TSession, TMetadata> scope)
 {
     return(_source.GetManagerForEntity(entity, scope));
 }