/// <inheritdoc />
        public QuerySingleResult QueryObject(QueryExpression expression)
        {
            string?id;

            if (expression.IsListQueryExpression)
            {
                id = IdParameterAsString(expression.AsListQueryExpression().Parameters.First());
            }
            else if (expression.IsMapQueryExpression)
            {
                id = IdParameterAsString(expression.AsMapQueryExpression().Parameters["id"]);
            }
            else
            {
                throw new StorageException(Result.Error, $"Unknown query type: {expression}");
            }

            var store = _stores.ComputeIfAbsent(expression.Type, type => new Dictionary <long, TState>());
            var found = id == null || id.Equals("-1") ? null ! : store[long.Parse(id)];

            var result = Optional
                         .OfNullable(found)
                         .Map(state => _stateAdapterProvider.FromRaw <StateObject, TState>(state))
                         .OrElse(null !);

            return(new QuerySingleResult(result));
        }