Пример #1
0
        internal JsonQueryBuilder(JsonQueryBuilderAdapter adapter, Func <object> commandResultAccessor)
        {
            Check.IsNotNull(adapter, nameof(adapter));
            Check.IsNotNull(commandResultAccessor, nameof(commandResultAccessor));

            this.adapter = adapter;
            this.commandResultAccessor = commandResultAccessor;
        }
Пример #2
0
        public JsonQueryBuilder QueryJson <TWrapper>(
            IWrapper <TWrapper> command,
            JsonQueryBuilderAdapter adapter)
            where TWrapper : PostgresQueryCommand, IWrapper <SelectClause>
        {
            Check.IsNotNull(command, nameof(command));

            commands.Add(command);

            var index = commands.Count - 1;

            queryResults.Add(x =>
            {
                // Join together multiple rows to handle SQL Server's insanity of splitting JSON (& XML) into 2033 character lines
                var result = x == null ? null : string.Join("", x.Select(y => y.FirstOrDefault().Value));

                return(result == null
                    ? null
                    : JsonConvert.DeserializeObject <JToken>(result.ToString()));
            });

            return(new JsonQueryBuilder(adapter, () => result?[index]));
        }