private ShardId GetAndRefreshExpectedShardId(object @object)
        {
            ShardId expectedShardId = shardIdResolver.GetShardIdForObject(@object);

            if (expectedShardId == null)
            {
                expectedShardId = ShardedSessionImpl.CurrentSubgraphShardId;
            }
            else
            {
                ShardedSessionImpl.CurrentSubgraphShardId = expectedShardId;
            }
            return(expectedShardId);
        }
        /// <summary>
        /// Set the ShardId if the entity is <see cref="IShardAware"/> and it ShardId is null.
        /// </summary>
        /// <param name="entity"></param>
        /// <returns>True if the state of the entity was changed</returns>
        private bool SetShardId(object entity)
        {
            if (entity is IShardAware)
            {
                IShardAware shardAware = (IShardAware)entity;

                if (shardAware.ShardId == null)
                {
                    shardAware.ShardId = shardIdResolver.GetShardIdForObject(entity);
                    return(true);
                }
            }
            return(false);
        }