Esempio n. 1
0
        public IJsonMappingBuilder QueryWithNesting(string propertyName, string query, string idColumn, Action <IJsonMappingBuilder> config)
        {
            if (propertyName == null)
            {
                throw new ArgumentNullException("propertyName cant be null");
            }
            if (query == null)
            {
                throw new ArgumentNullException("query cant be null");
            }
            if (idColumn == null)
            {
                throw new ArgumentNullException("idColumn cant be null");
            }
            if (config == null)
            {
                throw new ArgumentNullException("config cant be null");
            }
            var builder     = new JsonMappingBuilder(this);
            var mappedQuery = new MappedQueryWithNestedResults(idColumn, query);

            builder.Result = mappedQuery;
            Result.MappedPropertyList.Add(new MappedProperty(propertyName, mappedQuery));
            config(builder);
            return(this);
        }
        internal static MappedQueryWithNestedResults CompileQueryWithNestedResults(QueryWithNestedResultsDefinition queryWithNestesResultsMapping)
        {
            if (queryWithNestesResultsMapping == null)
            {
                throw new ArgumentNullException("queryWithNestesResultsMapping cant be null");
            }
            MappedQueryWithNestedResults newMappedQueryWithNestedResults = new MappedQueryWithNestedResults(queryWithNestesResultsMapping.IdColumn, queryWithNestesResultsMapping.Query);
            var template = queryWithNestesResultsMapping.Template;

            CompileProperties(template, newMappedQueryWithNestedResults, queryWithNestesResultsMapping);
            return(newMappedQueryWithNestedResults);
        }
Esempio n. 3
0
        internal void WriteQueryWithNestedResults(MappedQueryWithNestedResults query, JsonTextWriter jsonWriter, ParentObject parentObject, IDictionary <string, object> context, MappedProperty mappedProperty)
        {
            if (query == null)
            {
                throw new ArgumentNullException("query cant be null");
            }
            if (jsonWriter == null)
            {
                throw new ArgumentNullException("jsonWriter cant be null");
            }
            var command = commandManager.GetCommandForQuery(query);

            using (var reader = command.Prepare(parentObject, context).ExecuteReader())
            {
                nestedQueryResultProcessor.ProcessResults(mappedProperty, query, reader, jsonWriter, (c, r, l) => WriteJsonObject(query, jsonWriter, c, r, l, parentObject, context));
            }
        }