/// <summary>
        /// Generates fetch for related objects.
        /// </summary>
        /// <param name="model">Model to use.</param>
        /// <returns>Generated string.</returns>
        public string BuildRelationFetch(Model model)
        {
            var builder = new CodeBuilderDomainDatabase();

            builder.Tab     = "\t\t\t";
            builder.Context = Context;
            var code = builder.BuildRelationObjects(model);

            return(code);
        }
        /// <summary>
        /// Build the validation code.
        /// </summary>
        /// <param name="model"></param>
        /// <returns></returns>
        public string BuildRowMapping(Model model)
        {
            var builder = new CodeBuilderDomainDatabase();

            builder.Tab     = "\t\t\t";
            builder.Context = Context;
            // Get list of models in the inheritance path for this model
            List <Model> modelChain = ModelUtils.GetModelInheritancePath(Context.AllModels, model.Name, true);

            var code = builder.BuildRowMapper(model, modelChain);

            return(code);
        }
        /// <summary>
        /// Build the validation code.
        /// </summary>
        /// <param name="model"></param>
        /// <param name="subs"></param>
        /// <returns></returns>
        public string BuildDbParams(Model model, IDictionary <string, string> subs)
        {
            var builder = new CodeBuilderDomainDatabase();

            builder.Tab     = "\t\t\t";
            builder.Context = Context;
            // Get list of models in the inheritance path for this model
            List <Model> modelChain = ModelUtils.GetModelInheritancePath(Context.AllModels, model.Name, true);

            var code   = builder.BuildDbParams(model, modelChain);
            var create = builder.BuildCreateParamsSql(model, modelChain);
            var update = builder.BuildUpdateParamsSql(model, modelChain);

            subs["<%= model.SqlDbParams %>"]       = code;
            subs["<%= model.SqlDbParamsCreate %>"] = create;
            subs["<%= model.SqlDbParamsUpdate %>"] = update;

            return(code);
        }