コード例 #1
0
    public static string GenerateClass(ISqlConnectionProvider sqlConnectionProvider, string sqlQuery, string className)
    {
        var cSharpProperties = GetCSharpProperties(sqlConnectionProvider, sqlQuery);
        var classText        = CSharpClassTextGenerator.GenerateClassText(className, cSharpProperties, CSharpClassTextGeneratorOptions.Default);

        return(classText.Trim());
    }
コード例 #2
0
    private static string GetCSharpClassFromAdoSchemaTableColumns(IList <CSharpProperty> cSharpProperties)
    {
        var cSharpClass   = CSharpClassTextGenerator.GenerateClassText("SysTypes", cSharpProperties, CSharpClassTextGeneratorOptions.Default);
        var compileResult = RoslynHelper.TryCompile(cSharpClass);

        compileResult.IsValid().Should().BeTrue();
        return(cSharpClass);
    }
    public static string GenerateClass(ISqlConnectionProvider sqlConnectionProvider, string sqlQuery, string className, CSharpClassTextGeneratorOptions?options = null)
    {
        options ??= CSharpClassTextGeneratorOptions.Default;
        var cSharpProperties = CSharpPropertyFactoryFromAdoDataReader.FromQuery(sqlConnectionProvider, sqlQuery);
        var cSharpClass      = CSharpClassTextGenerator.GenerateClassText(className, cSharpProperties, options);

        return(cSharpClass);
    }
コード例 #4
0
    public static string GenerateClass(SqlTable table, string className = null)
    {
        var cSharpProperties = table.SqlColumns
                               .Select(CSharpPropertyFactoryFromSqlColumn.ToCSharpProperty)
                               .ToList();

        className = className ?? table.Name;
        var cSharpClass = CSharpClassTextGenerator.GenerateClassText(className, cSharpProperties, CSharpClassTextGeneratorOptions.Default);

        return(cSharpClass);
    }
    public static string CreateCSharpClass(IEnumerable <SISColumn> schemaColumns,
                                           string tableName,
                                           CSharpClassTextGeneratorOptions generatorOptions)
    {
        generatorOptions ??= CSharpClassTextGeneratorOptions.Default;

        var sqlColumns       = schemaColumns.Select(InformationSchemaColumnToSqlColumn).ToList();
        var cSharpProperties = sqlColumns.Select(CSharpPropertyFactoryFromSqlColumn.ToCSharpProperty).ToList();

        var classText =
            CSharpClassTextGenerator.GenerateClassText(tableName,
                                                       cSharpProperties,
                                                       generatorOptions);

        return(classText.Trim());
    }