public override object Hydrate(DbDataReader rs, string[] names, ISessionImplementor session, object owner) { if (owner == null && names.Length > 0) { // return the (fully resolved) identifier value, but do not resolve // to the actual referenced entity instance return(GetIdentifierOrUniqueKeyType(session.Factory) .NullSafeGet(rs, names, session, null)); } IType type = GetIdentifierOrUniqueKeyType(session.Factory); object identifier = session.GetContextEntityIdentifier(owner); //This ugly mess is only used when mapping one-to-one entities with component ID types if (type.IsComponentType && type is EmbeddedComponentType componentType) { EmbeddedComponentType ownerIdType = session.GetEntityPersister(null, owner).IdentifierType as EmbeddedComponentType; if (ownerIdType != null) { object[] values = ownerIdType.GetPropertyValues(identifier, session); object id = componentType.ResolveIdentifier(values, session, null); IEntityPersister persister = session.Factory.GetEntityPersister(type.ReturnedClass.FullName); var key = session.GenerateEntityKey(id, persister); return(session.PersistenceContext.GetEntity(key)); } } return(identifier); }
public override async Task <object> HydrateAsync(DbDataReader rs, string[] names, ISessionImplementor session, object owner, CancellationToken cancellationToken) { cancellationToken.ThrowIfCancellationRequested(); if (owner == null && names.Length > 0) { // return the (fully resolved) identifier value, but do not resolve // to the actual referenced entity instance return(await(GetIdentifierOrUniqueKeyType(session.Factory) .NullSafeGetAsync(rs, names, session, null, cancellationToken)).ConfigureAwait(false)); } IType type = GetIdentifierOrUniqueKeyType(session.Factory); object identifier = session.GetContextEntityIdentifier(owner); //This ugly mess is only used when mapping one-to-one entities with component ID types if (type.IsComponentType && type is EmbeddedComponentType componentType) { EmbeddedComponentType ownerIdType = session.GetEntityPersister(null, owner).IdentifierType as EmbeddedComponentType; if (ownerIdType != null) { object[] values = await(ownerIdType.GetPropertyValuesAsync(identifier, session, cancellationToken)).ConfigureAwait(false); object id = await(componentType.ResolveIdentifierAsync(values, session, null, cancellationToken)).ConfigureAwait(false); IEntityPersister persister = session.Factory.GetEntityPersister(type.ReturnedClass.FullName); var key = session.GenerateEntityKey(id, persister); return(session.PersistenceContext.GetEntity(key)); } } return(identifier); }
public override object Hydrate(DbDataReader rs, string[] names, ISessionImplementor session, object owner) { IType type = GetIdentifierOrUniqueKeyType(session.Factory); object identifier = session.GetContextEntityIdentifier(owner); //This ugly mess is only used when mapping one-to-one entities with component ID types EmbeddedComponentType componentType = type as EmbeddedComponentType; if (componentType != null) { EmbeddedComponentType ownerIdType = session.GetEntityPersister(null, owner).IdentifierType as EmbeddedComponentType; if (ownerIdType != null) { object[] values = ownerIdType.GetPropertyValues(identifier, session); object id = componentType.ResolveIdentifier(values, session, null); IEntityPersister persister = session.Factory.GetEntityPersister(type.ReturnedClass.FullName); var key = session.GenerateEntityKey(id, persister); return(session.PersistenceContext.GetEntity(key)); } } return(identifier); }
public override async Task <object> HydrateAsync(DbDataReader rs, string[] names, ISessionImplementor session, object owner, CancellationToken cancellationToken) { cancellationToken.ThrowIfCancellationRequested(); IType type = GetIdentifierOrUniqueKeyType(session.Factory); object identifier = session.GetContextEntityIdentifier(owner); //This ugly mess is only used when mapping one-to-one entities with component ID types EmbeddedComponentType componentType = type as EmbeddedComponentType; if (componentType != null) { EmbeddedComponentType ownerIdType = session.GetEntityPersister(null, owner).IdentifierType as EmbeddedComponentType; if (ownerIdType != null) { object[] values = await(ownerIdType.GetPropertyValuesAsync(identifier, session, cancellationToken)).ConfigureAwait(false); object id = await(componentType.ResolveIdentifierAsync(values, session, null, cancellationToken)).ConfigureAwait(false); IEntityPersister persister = session.Factory.GetEntityPersister(type.ReturnedClass.FullName); var key = session.GenerateEntityKey(id, persister); return(session.PersistenceContext.GetEntity(key)); } } return(identifier); }