Пример #1
0
        internal Mappings WithFailed(Mapping mapping)
        {
            var created = Created.Contains(mapping) ? Array.AsReadOnly(Created.Where(t => t != mapping).ToArray()) : Created;
            var failed  = !Failed.Contains(mapping) ? Array.AsReadOnly(Failed.Concat(new[] { mapping }).ToArray()) : Failed;
            var pending = Pending.Contains(mapping) ? Array.AsReadOnly(Pending.Where(t => t != mapping).ToArray()) : Pending;

            return(new Mappings(created, pending, failed));
        }
Пример #2
0
        internal Mappings Remove(Mapping mapping, out bool wasCreated)
        {
            wasCreated = Created.Contains(mapping);
            var created = Created.Contains(mapping) ? Created.Except(new[] { mapping }).ToArray() : Created;
            var pending = Pending.Contains(mapping) ? Pending.Except(new[] { mapping }).ToArray() : Pending;
            var failed  = Failed.Contains(mapping) ? Failed.Except(new[] { mapping }).ToArray() : Failed;

            return(new Mappings(created, pending, failed));
        }
Пример #3
0
        public void Create(IActiveRecord record)
        {
            if (record == null)
            {
                return;
            }

            if (Created.Contains(record))
            {
                return;
            }

            OnBeforeCreate(new ActiveRecordTransactionEventArgs(record));

            _created.Add(record);
        }