/// <summary>
        /// Attempts to extract <see cref="ShardId"/> from the entity identifier. This 
        /// will only work if the shard identifier has been encoded into the entity 
        /// identifier by an <see cref="IShardEncodingIdentifierGenerator"/>.
        /// </summary>
        /// <param name="shardedSessionFactory">The sharded session factory to use to retrieve entity metadata.</param>
        /// <param name="key">The entity key.</param>
        /// <param name="result">Returns the extracted <see cref="ShardId"/> if this operation succeeds.</param>
        /// <returns>Returns <c>true</c> if this operation succeeds or false otherwise.</returns>
        public static bool TryExtractShardIdFromKey(
            this IShardedSessionFactoryImplementor shardedSessionFactory, ShardedEntityKey key, out ShardId result)
        {
            var sessionFactory = shardedSessionFactory.ControlFactory;
            var entityPersister = sessionFactory.GetEntityPersister(key.EntityName);
            var rootEntityName = entityPersister.RootEntityName;

            var idGenerator = sessionFactory.GetIdentifierGenerator(rootEntityName) as IShardEncodingIdentifierGenerator;
            if (idGenerator != null)
            {
                result = idGenerator.ExtractShardId(key.Id);
                return true;
            }

            result = null;
            return false;
        }
        /// <summary>
        /// Attempts to extract <see cref="ShardId"/> from the entity identifier. This
        /// will only work if the shard identifier has been encoded into the entity
        /// identifier by an <see cref="IShardEncodingIdentifierGenerator"/>.
        /// </summary>
        /// <param name="shardedSessionFactory">The sharded session factory to use to retrieve entity metadata.</param>
        /// <param name="key">The entity key.</param>
        /// <param name="result">Returns the extracted <see cref="ShardId"/> if this operation succeeds.</param>
        /// <returns>Returns <c>true</c> if this operation succeeds or false otherwise.</returns>
        public static bool TryExtractShardIdFromKey(
            this IShardedSessionFactoryImplementor shardedSessionFactory, ShardedEntityKey key, out ShardId result)
        {
            var sessionFactory  = shardedSessionFactory.ControlFactory;
            var entityPersister = sessionFactory.GetEntityPersister(key.EntityName);
            var rootEntityName  = entityPersister.RootEntityName;

            var idGenerator = sessionFactory.GetIdentifierGenerator(rootEntityName) as IShardEncodingIdentifierGenerator;

            if (idGenerator != null)
            {
                result = idGenerator.ExtractShardId(key.Id);
                return(true);
            }

            result = null;
            return(false);
        }
 public override IEnumerable<ShardId> ResolveShardIds(ShardedEntityKey id)
 {
     return ShardIds;
 }
 public abstract IEnumerable<ShardId> ResolveShardIds(ShardedEntityKey id);