예제 #1
0
        public bool Insert(T obj)
        {
            Debug.Assert(typeof(T) == obj.GetType(), AssertNotDerivedTypesMsg);

            var keyBytes   = KeyBytes(obj);
            var valueBytes = ValueBytes(obj);

            StartWorkingWithPK();

            if (_transaction.KeyValueDBTransaction.Find(keyBytes) == FindResult.Exact)
            {
                return(false);
            }
            _transaction.KeyValueDBTransaction.CreateOrUpdateKeyValue(keyBytes, valueBytes);

            if (HasSecondaryIndexes)
            {
                AddIntoSecondaryIndexes(obj);
            }

            _modificationCounter.MarkModification();
            return(true);
        }
예제 #2
0
        public bool Insert(T obj)
        {
            Debug.Assert(typeof(T) == obj.GetType(), AssertNotDerivedTypesMsg);

            var keyBytes   = KeyBytes(obj);
            var valueBytes = ValueBytes(obj);

            ResetKeyPrefix();

            if (_kvtr.Find(keyBytes) == FindResult.Exact)
            {
                return(false);
            }

            _kvtr.CreateOrUpdateKeyValue(keyBytes, valueBytes);

            if (_hasSecondaryIndexes)
            {
                AddIntoSecondaryIndexes(obj);
            }

            _modificationCounter.MarkModification();
            return(true);
        }