Esempio n. 1
0
        public IReadOnlyDictionary <DbEntity, IReadOnlyList <ValidationError> > ValidateForDelete(IReadOnlyList <DbEntity> entities)
        {
            IDbWrite writeDb = null;

            foreach (var entity in entities)
            {
                var db = entity?.DbInternal;
                if (db == null)
                {
                    throw new InvalidOperationException("The Db instance is NULL which is not allowed. You are probably trying to delete an Entity which is not yet in the DB and therefore can not be deleted.");
                }

                var currentWriteDb = db as IDbWrite;
                if (currentWriteDb == null)
                {
                    throw new InvalidOperationException("You are trying to validate for delete with a Db which does not support writes. You propably did not intend this.");
                }

                if (writeDb != null && currentWriteDb != writeDb)
                {
                    throw new InvalidOperationException("ValidateForDelete was called with entities from different Dbs. This is not valid because they are going to be submitted with the same Db.");
                }
                writeDb = writeDb ?? currentWriteDb;
            }

            return(ValidateForDeleteGeneric(writeDb, entities.Where(e => e is T).Select(e => (T)e).ToList()));
        }
Esempio n. 2
0
 public IReadOnlyList <IAggregateUpdate> GetAggregateUpdates(IDbWrite db)
 {
     return(Array.Empty <IAggregateUpdate>());
 }
Esempio n. 3
0
 public Editor(PrimoContext newContext)
 {
     _dbWrite = new DbWrite(newContext);
     _dbRead  = new DbRead(newContext);
 }
Esempio n. 4
0
 internal IEnumerable <TElement> SelectBy(IDbWrite db, string column, object value)
 {
     return(db.Load <TElement>("SELECT " + string.Format(ColumnsString, FullTableName) + " FROM " + FullTableName + " WHERE " + column + " = @0", value));
 }
Esempio n. 5
0
 protected abstract IReadOnlyDictionary <DbEntity, IReadOnlyList <ValidationError> > ValidateForDeleteGeneric(IDbWrite writeDb, IReadOnlyList <T> entities);