<commit_before>﻿using System;
using System.Collections.Generic;
using System.Text;

namespace Threax.ModelGen
{
    public static class QueryModelWriter
    {
        public static String Get(String ns, String modelName)
        {
            String Model, model;
            NameGenerator.CreatePascalAndCamel(modelName, out Model, out model);
            return Create(ns, Model, model);
        }

        private static String Create(String ns, String Model, String model)
        {
            return
$@"using Halcyon.HAL.Attributes;
using {ns}.Controllers;
using {ns}.Models;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using Threax.AspNetCore.Halcyon.Ext;

namespace {ns}.ViewModels
{{
    [HalModel]
    public class {Model}Query : PagedCollectionQuery, I{Model}Query
    {{
        /// <summary>
        /// Lookup a {model} by id.
        /// </summary>
        public Guid? {Model}Id {{ get; set; }}

        //Add any additional query parameters here

        /// <summary>
        /// Populate an IQueryable for {model}s. Does not apply the skip or limit.
        /// </summary>
        /// <param name=""query"">The query to populate.</param>
        /// <returns>The query passed in populated with additional conditions.</returns>
        public IQueryable<T> Create<T>(IQueryable<T> query) where T : I{Model}, I{Model}Id
        {{
            if ({Model}Id.HasValue)
            {{
                query = query.Where(i => i.{Model}Id == {Model}Id);
            }}
            else
            {{
                //Put additional model query conditions here, this way id lookup always works
            }}

            return query;
        }}
    }}
}}";
        }
    }
}
<commit_msg>Fixed namespace for input model.<commit_after>﻿using System;
using System.Collections.Generic;
using System.Text;

namespace Threax.ModelGen
{
    public static class QueryModelWriter
    {
        public static String Get(String ns, String modelName)
        {
            String Model, model;
            NameGenerator.CreatePascalAndCamel(modelName, out Model, out model);
            return Create(ns, Model, model);
        }

        private static String Create(String ns, String Model, String model)
        {
            return
$@"using Halcyon.HAL.Attributes;
using {ns}.Controllers;
using {ns}.Models;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using Threax.AspNetCore.Halcyon.Ext;

namespace {ns}.InputModels
{{
    [HalModel]
    public class {Model}Query : PagedCollectionQuery, I{Model}Query
    {{
        /// <summary>
        /// Lookup a {model} by id.
        /// </summary>
        public Guid? {Model}Id {{ get; set; }}

        //Add any additional query parameters here

        /// <summary>
        /// Populate an IQueryable for {model}s. Does not apply the skip or limit.
        /// </summary>
        /// <param name=""query"">The query to populate.</param>
        /// <returns>The query passed in populated with additional conditions.</returns>
        public IQueryable<T> Create<T>(IQueryable<T> query) where T : I{Model}, I{Model}Id
        {{
            if ({Model}Id.HasValue)
            {{
                query = query.Where(i => i.{Model}Id == {Model}Id);
            }}
            else
            {{
                //Put additional model query conditions here, this way id lookup always works
            }}

            return query;
        }}
    }}
}}";
        }
    }
}

{'fraction_non_alphanumeric': 0.11636466591166478, 'fraction_numerical': 0.0, 'mean_word_length': 2.030017152658662, 'pattern_counts': {'":': 0, '<': 25, '<?xml version=': 0, '>': 27, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5446224', 'n_tokens_mistral': 975, 'n_tokens_neox': 962, 'n_words': 282}