internal async Task DeleteObjectByOIDAsync(int oid, SqoTypeInfo tinf) { ObjectSerializer serializer = SerializerFactory.GetSerializer(this.path, GetFileByType(tinf), useElevatedTrust); await this.MarkObjectAsDeleteAsync(serializer, oid, tinf).ConfigureAwait(false); }
internal async Task <int> SaveObjectAsync(object oi, SqoTypeInfo ti) { ObjectInfo objInfo = MetaExtractor.GetObjectInfo(oi, ti, metaCache); return(await this.SaveObjectAsync(oi, ti, objInfo).ConfigureAwait(false)); }
internal void DeleteObjectByOID(int oid, SqoTypeInfo tinf) { ObjectSerializer serializer = SerializerFactory.GetSerializer(this.path, GetFileByType(tinf), useElevatedTrust); this.MarkObjectAsDelete(serializer, oid, tinf); }
internal int SaveObject(object oi, SqoTypeInfo ti) { ObjectInfo objInfo = MetaExtractor.GetObjectInfo(oi, ti, metaCache); return(this.SaveObject(oi, ti, objInfo)); }
internal async Task <int> DeleteObjectByAsync(string[] fieldNames, object obj, SqoTypeInfo ti, Transaction transaction) { ObjectInfo objInfo = MetaExtractor.GetObjectInfo(obj, ti, metaCache); int i = 0; ICriteria wPrev = null; foreach (string fieldName in fieldNames) { FieldSqoInfo fi = MetaHelper.FindField(ti.Fields, fieldName); if (fi == null) { throw new SiaqodbException("Field:" + fieldName + " was not found as member of Type:" + ti.TypeName); } Where w = new Where(fieldName, OperationType.Equal, objInfo.AtInfo[fi]); w.StorageEngine = this; w.ParentSqoTypeInfo = ti; w.ParentType.Add(w.ParentSqoTypeInfo.Type); if (i > 0) { And and = new And(); and.Add(w, wPrev); wPrev = and; } else { wPrev = w; } i++; } List <int> oids = await wPrev.GetOIDsAsync().ConfigureAwait(false); if (oids.Count > 1) { throw new SiaqodbException("In database exists more than one object with value of fields specified"); } else if (oids.Count == 1) { objInfo.Oid = oids[0]; //obj.OID = oids[0]; metaCache.SetOIDToObject(obj, oids[0], ti); ObjectSerializer serializer = SerializerFactory.GetSerializer(this.path, GetFileByType(ti), useElevatedTrust); if (transaction == null) { await CheckForConcurencyAsync(obj, objInfo, ti, serializer, true).ConfigureAwait(false); await this.MarkObjectAsDeleteAsync(serializer, objInfo.Oid, ti).ConfigureAwait(false); await this.indexManager.UpdateIndexesAfterDeleteAsync(objInfo, ti).ConfigureAwait(false); } else { await this.DeleteObjectAsync(obj, ti, transaction, objInfo).ConfigureAwait(false); } return(oids[0]); } else { return(-1); } }
internal bool UpdateObjectBy(string[] fieldNames, object obj, SqoTypeInfo ti, Transaction transact) { ObjectInfo objInfo = MetaExtractor.GetObjectInfo(obj, ti, metaCache); int i = 0; ICriteria wPrev = null; foreach (string fieldName in fieldNames) { FieldSqoInfo fi = MetaHelper.FindField(ti.Fields, fieldName); if (fi == null) { throw new SiaqodbException("Field:" + fieldName + " was not found as member of Type:" + ti.TypeName); } Where w = new Where(fieldName, OperationType.Equal, objInfo.AtInfo[fi]); w.StorageEngine = this; w.ParentSqoTypeInfo = ti; w.ParentType.Add(w.ParentSqoTypeInfo.Type); if (i > 0) { And and = new And(); and.Add(w, wPrev); wPrev = and; } else { wPrev = w; } i++; } List <int> oids = wPrev.GetOIDs(); if (oids.Count > 1) { throw new SiaqodbException("In database exists more than one object with value of fields specified"); } else if (oids.Count == 1) { objInfo.Oid = oids[0]; #region old code that was duplicated like on SaveObject /*//obj.OID = oids[0]; * MetaHelper.SetOIDToObject(obj, oids[0], ti.Type); * * lock (_syncRoot) * { * ObjectSerializer serializer = SerializerFactory.GetSerializer(this.path, GetFileByType(ti), useElevatedTrust); * * CheckForConcurency(obj, objInfo, ti, serializer,false); * * CheckConstraints(objInfo, ti); * * Dictionary<string, object> oldValuesOfIndexedFields = this.PrepareUpdateIndexes(objInfo, ti, serializer); * * serializer.SerializeObject(objInfo); * * this.UpdateIndexes(objInfo, ti, oldValuesOfIndexedFields); * }*/ #endregion if (transact == null) { this.SaveObject(obj, ti, objInfo); } else { this.SaveObject(obj, ti, objInfo, transact); } return(true); } else { return(false); } }
internal async Task <bool> UpdateObjectByAsync(string[] fieldNames, object obj, SqoTypeInfo ti, Transaction transact) { ObjectInfo objInfo = MetaExtractor.GetObjectInfo(obj, ti, metaCache); int i = 0; ICriteria wPrev = null; foreach (string fieldName in fieldNames) { FieldSqoInfo fi = MetaHelper.FindField(ti.Fields, fieldName); if (fi == null) { throw new SiaqodbException("Field:" + fieldName + " was not found as member of Type:" + ti.TypeName); } Where w = new Where(fieldName, OperationType.Equal, objInfo.AtInfo[fi]); w.StorageEngine = this; w.ParentSqoTypeInfo = ti; w.ParentType.Add(w.ParentSqoTypeInfo.Type); if (i > 0) { And and = new And(); and.Add(w, wPrev); wPrev = and; } else { wPrev = w; } i++; } List <int> oids = await wPrev.GetOIDsAsync().ConfigureAwait(false); if (oids.Count > 1) { throw new SiaqodbException("In database exists more than one object with value of fields specified"); } else if (oids.Count == 1) { objInfo.Oid = oids[0]; if (transact == null) { await this.SaveObjectAsync(obj, ti, objInfo).ConfigureAwait(false); } else { await this.SaveObjectAsync(obj, ti, objInfo, transact).ConfigureAwait(false); } return(true); } else { return(false); } }
internal void AdjustArrayFieldsAfterShrink(SqoTypeInfo ti, FieldSqoInfo fi, int objectOID, int newOID) { ObjectSerializer serializer = SerializerFactory.GetSerializer(this.path, GetFileByType(ti), useElevatedTrust); serializer.SaveArrayOIDFieldContent(ti, fi, objectOID, newOID); }
internal int InsertObjectByMeta(SqoTypeInfo tinf) { ObjectSerializer serializer = SerializerFactory.GetSerializer(this.path, GetFileByType(tinf), useElevatedTrust); return(serializer.InsertEmptyObject(tinf)); }
internal int SaveObjectBytes(byte[] objBytes, SqoTypeInfo ti) { ObjectSerializer serializer = SerializerFactory.GetSerializer(this.path, GetFileByType(ti), useElevatedTrust); return(serializer.SerializeObjectWithNewOID(objBytes, ti)); }
internal async Task <int> SaveObjectBytesAsync(byte[] objBytes, SqoTypeInfo ti) { ObjectSerializer serializer = SerializerFactory.GetSerializer(this.path, GetFileByType(ti), useElevatedTrust); return(await serializer.SerializeObjectWithNewOIDAsync(objBytes, ti).ConfigureAwait(false)); }
internal void SetFileLength(long newLength, SqoTypeInfo ti) { ObjectSerializer serializer = SerializerFactory.GetSerializer(this.path, GetFileByType(ti), useElevatedTrust); serializer.SetLength(newLength); }
internal static long GetSeekPosition(SqoTypeInfo ti, int oid) { long position = (long)ti.Header.headerSize + (long)((long)(oid - 1) * (long)ti.Header.lengthOfRecord); return(position); }
internal QueryTranslator(StorageEngine engine, SqoTypeInfo ti) { this.engine = engine; this.ti = ti; }
public void AddTypeInfo(SqoTypeInfo ti) { dict[ti] = new ConditionalWeakTable(); }
public ComplexTypeTransformer(ObjectSerializer serializer, SqoTypeInfo ti, FieldSqoInfo fi) { this.serializer = serializer; this.fi = fi; this.ti = ti; }