public void GenerateRepositorySource(string writeSourceTo, string schemaName = null)
        {
            schemaName = schemaName ?? SchemaName;
            SchemaName = schemaName;
            base.GenerateSource(writeSourceTo);
            SchemaRepositoryModel schemaModel = new SchemaRepositoryModel
            {
                BaseRepositoryType        = BaseRepositoryType,
                BaseNamespace             = SourceNamespace,
                SchemaRepositoryNamespace = SchemaRepositoryNamespace,
                SchemaName = schemaName,
                Types      = Types.Select(t => SchemaTypeModel.FromType(t, DaoNamespace)).ToArray()
            };
            string code = schemaModel.Render();

            code.SafeWriteToFile(Path.Combine(writeSourceTo, $"{schemaName}Repository.cs"));
        }
        public virtual void GenerateRepositorySource(string writeSourceTo, string schemaName = null)
        {
            Args.ThrowIfNull(TemplateRenderer, "TemplateRenderer");

            schemaName = schemaName ?? SchemaName;
            SchemaName = schemaName;
            base.GenerateSource(writeSourceTo);
            SchemaRepositoryModel schemaModel = new SchemaRepositoryModel
            {
                BaseRepositoryType        = BaseRepositoryType,
                BaseNamespace             = SourceNamespace,
                SchemaRepositoryNamespace = SchemaRepositoryNamespace,
                SchemaName = schemaName,
                Types      = Types.Select(GetSchemaTypeModel).ToArray()
            };

            string filePath = Path.Combine(writeSourceTo, $"{schemaName}Repository.cs");

            if (File.Exists(filePath))
            {
                File.Move(filePath, filePath.GetNextFileName());
            }
            TemplateRenderer.Render("SchemaRepository", schemaModel, new FileStream(filePath, FileMode.Create));
        }