public ForeignKeyDefinition AddForeignKey(MemberInfo[] members, Type referenceType) { var referenceMapping = _storeOptions.MappingFor(referenceType); var duplicateField = DuplicateField(members); var foreignKey = new ForeignKeyDefinition(duplicateField.ColumnName, this, referenceMapping); ForeignKeys.Add(foreignKey); return(foreignKey); }
public DocumentTable(DocumentMapping mapping) : base(mapping.Table) { // validate to ensure document has an Identity field or property mapping.Validate(); var pgIdType = TypeMappings.GetPgType(mapping.IdMember.GetMemberType()); var pgTextType = TypeMappings.GetPgType(string.Empty.GetType()); var idColumn = new TableColumn("id", pgIdType); if (mapping.TenancyStyle == TenancyStyle.Conjoined) { AddPrimaryKeys(new List <TableColumn> { idColumn, new TenantIdColumn() }); Indexes.Add(new IndexDefinition(mapping, TenantIdColumn.Name)); } else { AddPrimaryKey(idColumn); } AddColumn("data", "jsonb", "NOT NULL"); AddColumn <LastModifiedColumn>(); AddColumn <VersionColumn>(); AddColumn <DotNetTypeColumn>(); foreach (var field in mapping.DuplicatedFields) { AddColumn(new DuplicatedFieldColumn(field)); } if (mapping.IsHierarchy()) { AddColumn(new DocumentTypeColumn(mapping)); } if (mapping.DeleteStyle == DeleteStyle.SoftDelete) { AddColumn <DeletedColumn>(); Indexes.Add(new IndexDefinition(mapping, DocumentMapping.DeletedColumn)); AddColumn <DeletedAtColumn>(); } Indexes.AddRange(mapping.Indexes); ForeignKeys.AddRange(mapping.ForeignKeys); }
/// <summary> /// Determine whether the entity is persistent, detached, or transient /// </summary> /// <param name="entity">The entity to check </param> /// <param name="entityName">The name of the entity </param> /// <param name="entry">The entity's entry in the persistence context </param> /// <param name="source">The originating session. </param> /// <param name="cancellationToken">A cancellation token that can be used to cancel the work</param> /// <returns> The state. </returns> protected virtual async Task <EntityState> GetEntityStateAsync(object entity, string entityName, EntityEntry entry, ISessionImplementor source, CancellationToken cancellationToken) { cancellationToken.ThrowIfCancellationRequested(); if (entry != null) { // the object is persistent //the entity is associated with the session, so check its status if (entry.Status != Status.Deleted) { // do nothing for persistent instances if (log.IsDebugEnabled) { log.Debug("persistent instance of: " + GetLoggableName(entityName, entity)); } return(EntityState.Persistent); } else { //ie. e.status==DELETED if (log.IsDebugEnabled) { log.Debug("deleted instance of: " + GetLoggableName(entityName, entity)); } return(EntityState.Deleted); } } else { //the object is transient or detached //the entity is not associated with the session, so //try interceptor and unsaved-value var assumed = AssumedUnsaved; if (assumed.HasValue ? (await(ForeignKeys.IsTransientFastAsync(entityName, entity, source, cancellationToken)).ConfigureAwait(false)).GetValueOrDefault(assumed.Value) : await(ForeignKeys.IsTransientSlowAsync(entityName, entity, source, cancellationToken)).ConfigureAwait(false)) { if (log.IsDebugEnabled) { log.Debug("transient instance of: " + GetLoggableName(entityName, entity)); } return(EntityState.Transient); } else { if (log.IsDebugEnabled) { log.Debug("detached instance of: " + GetLoggableName(entityName, entity)); } return(EntityState.Detached); } } }
public void OnSelectedEntityChanged() { SelectedForeignKey = null; ForeignKeys.Clear(); if (SelectedEntity == null) { SelectedEntityCaption = ""; } else { SelectedEntityCaption = SelectedEntity.CodeElementFullName; } }
private void LoadForeignKeys() { string[] restrictions = new string[4] { null, _owningNode.Database, Name, null }; DataTable dt = _owningNode.GetSchema("Foreign Keys", restrictions); foreach (DataRow row in dt.Rows) { ForeignKey key = new ForeignKey(this, row); ForeignKeys.Add(key); } }
internal async Task <bool> CanSkipElementExistenceCheckAsync(object element, CancellationToken cancellationToken) { cancellationToken.ThrowIfCancellationRequested(); var queryableCollection = (IQueryableCollection)Session.Factory.GetCollectionPersister(Role); return (queryableCollection != null && queryableCollection.ElementType.IsEntityType && !queryableCollection.ElementPersister.EntityMetamodel.OverridesEquals && !element.IsProxy() && !Session.PersistenceContext.IsEntryFor(element) && await(ForeignKeys.IsTransientFastAsync(queryableCollection.ElementPersister.EntityName, element, Session, cancellationToken)).ConfigureAwait(false) == true); }
/// <summary> /// Determine whether the entity is persistent, detached, or transient /// </summary> /// <param name="entity">The entity to check </param> /// <param name="entityName">The name of the entity </param> /// <param name="entry">The entity's entry in the persistence context </param> /// <param name="source">The originating session. </param> /// <returns> The state. </returns> protected virtual EntityState GetEntityState(object entity, string entityName, EntityEntry entry, ISessionImplementor source) { if (entry != null) { // the object is persistent //the entity is associated with the session, so check its status if (entry.Status != Status.Deleted) { // do nothing for persistent instances if (log.IsDebugEnabled) { log.Debug("persistent instance of: " + GetLoggableName(entityName, entity)); } return(EntityState.Persistent); } else { //ie. e.status==DELETED if (log.IsDebugEnabled) { log.Debug("deleted instance of: " + GetLoggableName(entityName, entity)); } return(EntityState.Deleted); } } else { //the object is transient or detached //the entity is not associated with the session, so //try interceptor and unsaved-value var assumed = AssumedUnsaved; if (assumed.HasValue ? ForeignKeys.IsTransientFast(entityName, entity, source).GetValueOrDefault(assumed.Value) : ForeignKeys.IsTransientSlow(entityName, entity, source)) { if (log.IsDebugEnabled) { log.Debug("transient instance of: " + GetLoggableName(entityName, entity)); } return(EntityState.Transient); } else { if (log.IsDebugEnabled) { log.Debug("detached instance of: " + GetLoggableName(entityName, entity)); } return(EntityState.Detached); } } }
public DocumentTable(DocumentMapping mapping) : base(mapping.TableName) { // validate to ensure document has an Identity field or property mapping.CompileAndValidate(); _mapping = mapping; var idColumn = new IdColumn(mapping); AddColumn(idColumn).AsPrimaryKey(); if (mapping.TenancyStyle == TenancyStyle.Conjoined) { AddColumn(mapping.Metadata.TenantId).AsPrimaryKey(); Indexes.Add(new DocumentIndex(mapping, TenantIdColumn.Name)); } AddColumn <DataColumn>(); AddIfActive(_mapping.Metadata.LastModified); AddIfActive(_mapping.Metadata.Version); AddIfActive(_mapping.Metadata.DotNetType); AddIfActive(_mapping.Metadata.CorrelationId); AddIfActive(_mapping.Metadata.CausationId); AddIfActive(_mapping.Metadata.LastModifiedBy); AddIfActive(_mapping.Metadata.Headers); foreach (var field in mapping.DuplicatedFields.Where(x => !x.OnlyForSearching)) { AddColumn(new DuplicatedFieldColumn(field)); } if (mapping.IsHierarchy()) { Indexes.Add(new DocumentIndex(_mapping, SchemaConstants.DocumentTypeColumn)); AddColumn(_mapping.Metadata.DocumentType); } if (mapping.DeleteStyle == DeleteStyle.SoftDelete) { AddColumn(_mapping.Metadata.IsSoftDeleted); Indexes.Add(new DocumentIndex(mapping, SchemaConstants.DeletedColumn)); AddColumn(_mapping.Metadata.SoftDeletedAt); } Indexes.AddRange(mapping.Indexes); ForeignKeys.AddRange(mapping.ForeignKeys); }
protected internal virtual Table Clone(CloneContext cloneContext) { var clone = new Table(Name, Columns.Select(c => c.Clone(cloneContext))); if (PrimaryKey != null) { clone._primaryKey = PrimaryKey.Clone(cloneContext); } clone._foreignKeys.AddRange(ForeignKeys.Select(fk => fk.Clone(cloneContext))); clone._indexes.AddRange(Indexes.Select(ix => ix.Clone(cloneContext))); return(clone); }
public override object Replace(object original, object current, ISessionImplementor session, object owner, IDictionary copiedAlready) { if (original == null) { return(null); } else { string entityName = session.BestGuessEntityName(original); object id = ForeignKeys.GetEntityIdentifierIfNotUnsaved(entityName, original, session); return(session.InternalLoad(entityName, id, false, false)); } }
/// <summary>Handle the given lock event. </summary> /// <param name="event">The lock event to be handled.</param> /// <param name="cancellationToken">A cancellation token that can be used to cancel the work</param> public virtual Task OnLockAsync(LockEvent @event, CancellationToken cancellationToken) { if (@event.Entity == null) { throw new NullReferenceException("attempted to lock null"); } if (@event.LockMode == LockMode.Write) { throw new HibernateException("Invalid lock mode for lock()"); } if (cancellationToken.IsCancellationRequested) { return(Task.FromCanceled <object>(cancellationToken)); } return(InternalOnLockAsync()); async Task InternalOnLockAsync() { ISessionImplementor source = @event.Session; if (@event.LockMode == LockMode.None && source.PersistenceContext.ReassociateIfUninitializedProxy(@event.Entity)) { // NH-specific: shortcut for uninitialized proxies - reassociate // without initialization return; } object entity = await(source.PersistenceContext.UnproxyAndReassociateAsync(@event.Entity, cancellationToken)).ConfigureAwait(false); //TODO: if object was an uninitialized proxy, this is inefficient,resulting in two SQL selects EntityEntry entry = source.PersistenceContext.GetEntry(entity); if (entry == null) { IEntityPersister persister = source.GetEntityPersister(@event.EntityName, entity); object id = persister.GetIdentifier(entity); if ((await(ForeignKeys.IsTransientFastAsync(@event.EntityName, entity, source, cancellationToken)).ConfigureAwait(false)).GetValueOrDefault()) { throw new TransientObjectException("cannot lock an unsaved transient instance: " + persister.EntityName); } entry = await(ReassociateAsync(@event, entity, id, persister, cancellationToken)).ConfigureAwait(false); await(CascadeOnLockAsync(@event, persister, entity, cancellationToken)).ConfigureAwait(false); } await(UpgradeLockAsync(entity, entry, @event.LockMode, source, cancellationToken)).ConfigureAwait(false); } }
public void EditNiceNames(ForeignKeys coll) { DataTable dt = ProLogForNiceNames(coll); DataRowCollection rows = dt.Rows; foreach (ForeignKey o in coll) { rows.Add(new object[] { o.Name, o.Alias, o }); } EpilogForNiceNames(dt); this._currentHashCode = coll.GetHashCode(); }
public static List<userTbl> getAllUsersByType(int numType) { List<loginAndPermissions> usersLogin = getLoginList(); List<userTbl> users = new List<userTbl>(); foreach(var user in usersLogin) { if(user.userType == numType) { userTbl userToList = ForeignKeys.getUserConnectedByID(user.id); users.Add(userToList); } } return users; }
protected internal Task <object> GetIdentifierAsync(object value, ISessionImplementor session, CancellationToken cancellationToken) { if (cancellationToken.IsCancellationRequested) { return(Task.FromCanceled <object>(cancellationToken)); } try { return(ForeignKeys.GetEntityIdentifierIfNotUnsavedAsync(GetAssociatedEntityName(), value, session, cancellationToken)); //tolerates nulls } catch (Exception ex) { return(Task.FromException <object>(ex)); } }
public override async Task <object> ReplaceAsync(object original, object current, ISessionImplementor session, object owner, IDictionary copiedAlready, CancellationToken cancellationToken) { cancellationToken.ThrowIfCancellationRequested(); if (original == null) { return(null); } else { string entityName = session.BestGuessEntityName(original); object id = await(ForeignKeys.GetEntityIdentifierIfNotUnsavedAsync(entityName, original, session, cancellationToken)).ConfigureAwait(false); return(await(session.InternalLoadAsync(entityName, id, false, false, cancellationToken)).ConfigureAwait(false)); } }
public ResourceBlockTable(DatabaseSchema databaseSchema) : base(databaseSchema) { Columns = new List <ISqlColumn> { Id, BlockOrder, FkPerson, FkPairPartner, FkProject, FkSchedule }; ForeignKeys.Add(new SqlForeignKey(FkPerson, PersonTable.TableName, PersonTable.Id)); ForeignKeys.Add(new SqlForeignKey(FkProject, ProjectTable.TableName, ProjectTable.Id)); ForeignKeys.Add(new SqlForeignKey(FkSchedule, WeeklyScheduleTable.TableName, WeeklyScheduleTable.Id)); }
public EntityStatus(IContext ctx) { _initMode = ctx.Process.Mode == "init"; if (ctx.Entity.IsMaster) { return; } var master = ctx.Process.Entities.First(e => e.IsMaster); MasterUpserted = master.Updates + master.Inserts > 0; Modified = ctx.Entity.Updates + ctx.Entity.Inserts + ctx.Entity.Deletes > 0; ForeignKeys.AddRange(ctx.Entity.Fields.Where(f => f.KeyType.HasFlag(KeyType.Foreign))); HasForeignKeys = ForeignKeys.Count > 0; }
/// <summary> /// Generates an identifier from the value of a Property. /// </summary> /// <param name="sessionImplementor">The <see cref="ISessionImplementor"/> this id is being generated in.</param> /// <param name="obj">The entity for which the id is being generated.</param> /// <param name="cancellationToken">A cancellation token that can be used to cancel the work</param> /// <returns> /// The identifier value from the associated object or /// <see cref="IdentifierGeneratorFactory.ShortCircuitIndicator"/> if the <c>session</c> /// already contains <c>obj</c>. /// </returns> public async Task <object> GenerateAsync(ISessionImplementor sessionImplementor, object obj, CancellationToken cancellationToken) { cancellationToken.ThrowIfCancellationRequested(); ISession session = (ISession)sessionImplementor; var persister = sessionImplementor.Factory.GetEntityPersister(entityName); object associatedObject = persister.GetPropertyValue(obj, propertyName); if (associatedObject == null) { throw new IdentifierGenerationException("attempted to assign id from null one-to-one property: " + propertyName); } EntityType foreignValueSourceType; IType propertyType = persister.GetPropertyType(propertyName); if (propertyType.IsEntityType) { foreignValueSourceType = (EntityType)propertyType; } else { // try identifier mapper foreignValueSourceType = (EntityType)persister.GetPropertyType("_identifierMapper." + propertyName); } object id; try { id = await(ForeignKeys.GetEntityIdentifierIfNotUnsavedAsync( foreignValueSourceType.GetAssociatedEntityName(), associatedObject, sessionImplementor, cancellationToken)).ConfigureAwait(false); } catch (TransientObjectException) { id = await(session.SaveAsync(foreignValueSourceType.GetAssociatedEntityName(), associatedObject, cancellationToken)).ConfigureAwait(false); } if (session.Contains(obj)) { //abort the save (the object is already saved by a circular cascade) return(IdentifierGeneratorFactory.ShortCircuitIndicator); } return(id); }
public void DoAnalise() { if (ForeignKeys.Count > 0) { CheckIsReady(); return; } if ((SelectedEntity == null) || (SelectedDbContext == null)) { SelectedForeignKey = null; ForeignKeys.Clear(); CheckIsReady(); return; } DoAnaliseEx(); }
public override object Disassemble(object value, ISessionImplementor session, object owner) { if (value == null) { return(null); } object id = ForeignKeys.GetEntityIdentifierIfNotUnsaved(GetAssociatedEntityName(), value, session); if (id == null) { throw new AssertionFailure("cannot cache a reference to an object with a null id: " + GetAssociatedEntityName()); } return(GetIdentifierType(session).Disassemble(id, session, owner)); }
public virtual Table Clone([NotNull] CloneContext cloneContext) { Check.NotNull(cloneContext, "cloneContext"); var clone = new Table(Name, Columns.Select(c => c.Clone(cloneContext))); if (PrimaryKey != null) { clone._primaryKey = PrimaryKey.Clone(cloneContext); } clone._foreignKeys.AddRange(ForeignKeys.Select(fk => fk.Clone(cloneContext))); clone._indexes.AddRange(Indexes.Select(ix => ix.Clone(cloneContext))); return(clone); }
public override object ToMinified() { var vs = Validators.Select(v => v.ToMinified()).ToList(); return(new { n = Name, r = ResourceName, l = GetDisplayName(), t = EntityTypeName, s = IsScalar == true ? true : (bool?)null, a = AssociationName, c = DoCascadeDelete == true ? true : (bool?)null, f = ForeignKeys.Any() ? ForeignKeys : null, v = vs.Any() ? vs : null }); }
public override async Task <object> DisassembleAsync(object value, ISessionImplementor session, object owner, CancellationToken cancellationToken) { cancellationToken.ThrowIfCancellationRequested(); if (value == null) { return(null); } object id = await(ForeignKeys.GetEntityIdentifierIfNotUnsavedAsync(GetAssociatedEntityName(), value, session, cancellationToken)).ConfigureAwait(false); if (id == null) { throw new AssertionFailure("cannot cache a reference to an object with a null id: " + GetAssociatedEntityName()); } return(await(GetIdentifierType(session).DisassembleAsync(id, session, owner, cancellationToken)).ConfigureAwait(false)); }
/// <summary> /// Generates an identifier from the value of a Property. /// </summary> /// <param name="sessionImplementor">The <see cref="ISessionImplementor"/> this id is being generated in.</param> /// <param name="obj">The entity for which the id is being generated.</param> /// <param name="cancellationToken">A cancellation token that can be used to cancel the work</param> /// <returns> /// The identifier value from the associated object or /// <see cref="IdentifierGeneratorFactory.ShortCircuitIndicator"/> if the <c>session</c> /// already contains <c>obj</c>. /// </returns> public async Task <object> GenerateAsync(ISessionImplementor sessionImplementor, object obj, CancellationToken cancellationToken) { cancellationToken.ThrowIfCancellationRequested(); var persister = sessionImplementor.Factory.GetEntityPersister(entityName); object associatedObject = persister.GetPropertyValue(obj, propertyName); if (associatedObject == null) { throw new IdentifierGenerationException("attempted to assign id from null one-to-one property: " + propertyName); } var foreignValueSourceType = GetForeignValueSourceType(persister); object id; try { id = await(ForeignKeys.GetEntityIdentifierIfNotUnsavedAsync( foreignValueSourceType.GetAssociatedEntityName(), associatedObject, sessionImplementor, cancellationToken)).ConfigureAwait(false); } catch (TransientObjectException) { if (sessionImplementor is ISession session) { id = await(session.SaveAsync(foreignValueSourceType.GetAssociatedEntityName(), associatedObject, cancellationToken)).ConfigureAwait(false); } else if (sessionImplementor is IStatelessSession statelessSession) { id = await(statelessSession.InsertAsync(foreignValueSourceType.GetAssociatedEntityName(), associatedObject, cancellationToken)).ConfigureAwait(false); } else { throw new IdentifierGenerationException("sessionImplementor is neither Session nor StatelessSession"); } } if (Contains(sessionImplementor, obj)) { //abort the save (the object is already saved by a circular cascade) return(IdentifierGeneratorFactory.ShortCircuitIndicator); } return(id); }
public override string ToString() { List <Type> sortedTables = Tables.ToList(); sortedTables.Sort((t1, t2) => t1.FullName.CompareTo(t2.FullName)); List <TypeFk> sortedForeignKeys = ForeignKeys.ToList(); sortedForeignKeys.Sort((f1, f2) => f1.Hash.CompareTo(f2.Hash)); List <TypeXref> sortedXrefs = Xrefs.ToList(); sortedXrefs.Sort((x1, x2) => x1.Hash.CompareTo(x2.Hash)); string tables = sortedTables.ToInfoString(); string tablesInfo = Tables.ToInfoHash(); string foreignKeyHashes = string.Join("\r\n\t", sortedForeignKeys.Select(fk => fk.Hash).ToArray()); string xrefHashes = string.Join("\r\n\t", sortedXrefs.Select(x => x.Hash).ToArray()); return($"{tables}\r\n{tablesInfo}\r\nFKHashes:\r\n\t{foreignKeyHashes}\r\nXrefHashes:\r\n\t{xrefHashes}"); }
public override object Disassemble(object value, ISessionImplementor session, object owner) { if (value == null) { return(null); } else { // cache the actual id of the object, not the value of the // property-ref, which might not be initialized object id = ForeignKeys.GetEntityIdentifierIfNotUnsaved(GetAssociatedEntityName(), value, session); if (id == null) { throw new AssertionFailure("cannot cache a reference to an object with a null id: " + GetAssociatedEntityName()); } return(GetIdentifierType(session).Disassemble(id, session, owner)); } }
/** * Adds a new foreign key to the foreign table, that supports a Many:1. * * > NOTE: This will be deferred until it comes time * > to actually create the foreign table. */ protected void AddFKToFT(RelationshipDiscoverer.Relation relation) { // Create a new ForeignKey, the creation is defered. ForeignKeys.Add(new ForeignKey { TableName = relation.ForeignKeyTableName, ColumnName = relation.ForeignKeyColumnName }); // Ensure the foreign key contraint gets added also. FkConstraints.Add(new FkConstraint { LocalTableName = relation.ForeignKeyTableName, LocalColumnName = relation.ForeignKeyColumnName, ForeignTableName = relation.LocalTableName, ForeignColumnName = "Id" }); }
/// <summary> /// Handles click on the add key button. /// </summary> /// <param name="sender">Sender of the event.</param> /// <param name="e">Detailed information about event.</param> private void OnAddKeyClick(object sender, EventArgs e) { if (ForeignKeys != null) { // Create new key DataRow newForeignKey = ForeignKeys.NewRow(); if (newForeignKey == null) { return; } // Add new key to table ForeignKeys.Rows.Add(newForeignKey); // Select new key in the list foreignKeysList.SetSelected(foreignKeysList.Items.Count - 1, true); } }
/// <summary> /// Given a collection of entity instances that used to /// belong to the collection, and a collection of instances /// that currently belong, return a collection of orphans /// </summary> protected virtual ICollection GetOrphans(ICollection oldElements, ICollection currentElements, string entityName, ISessionImplementor session) { // short-circuit(s) if (currentElements.Count == 0) { // no new elements, the old list contains only Orphans return(oldElements); } if (oldElements.Count == 0) { // no old elements, so no Orphans neither return(oldElements); } IType idType = session.Factory.GetEntityPersister(entityName).IdentifierType; // create the collection holding the orphans List <object> res = new List <object>(); // collect EntityIdentifier(s) of the *current* elements - add them into a HashSet for fast access var currentIds = new HashSet <TypedValue>(); foreach (object current in currentElements) { if (current != null && ForeignKeys.IsNotTransient(entityName, current, null, session)) { object currentId = ForeignKeys.GetEntityIdentifierIfNotUnsaved(entityName, current, session); currentIds.Add(new TypedValue(idType, currentId, session.EntityMode)); } } // iterate over the *old* list foreach (object old in oldElements) { object oldId = ForeignKeys.GetEntityIdentifierIfNotUnsaved(entityName, old, session); if (!currentIds.Contains(new TypedValue(idType, oldId, session.EntityMode))) { res.Add(old); } } return(res); }
/// <summary> /// Given a collection of entity instances that used to /// belong to the collection, and a collection of instances /// that currently belong, return a collection of orphans /// </summary> protected virtual async Task <ICollection> GetOrphansAsync(ICollection oldElements, ICollection currentElements, string entityName, ISessionImplementor session, CancellationToken cancellationToken) { cancellationToken.ThrowIfCancellationRequested(); // short-circuit(s) if (currentElements.Count == 0) { // no new elements, the old list contains only Orphans return(oldElements); } if (oldElements.Count == 0) { // no old elements, so no Orphans neither return(oldElements); } IType idType = session.Factory.GetEntityPersister(entityName).IdentifierType; // create the collection holding the orphans List <object> res = new List <object>(); // collect EntityIdentifier(s) of the *current* elements - add them into a HashSet for fast access var currentIds = new HashSet <TypedValue>(); foreach (object current in currentElements) { if (current != null && await(ForeignKeys.IsNotTransientSlowAsync(entityName, current, session, cancellationToken)).ConfigureAwait(false)) { object currentId = await(ForeignKeys.GetEntityIdentifierIfNotUnsavedAsync(entityName, current, session, cancellationToken)).ConfigureAwait(false); currentIds.Add(new TypedValue(idType, currentId)); } } // iterate over the *old* list foreach (object old in oldElements) { object oldId = await(ForeignKeys.GetEntityIdentifierIfNotUnsavedAsync(entityName, old, session, cancellationToken)).ConfigureAwait(false); if (!currentIds.Contains(new TypedValue(idType, oldId))) { res.Add(old); } } return(res); }