Table of Contents

Method ReadSchema

Namespace
YndigoBlue.Velocity.Engine
Assembly
YndigoBlue.Velocity.dll

ReadSchema(string, ConfigType)

Reads a schema definition from a string and returns an in-memory Schema object.

public Schema ReadSchema(string contents, ConfigType configType)

Parameters

contents string

A string containing a Velocity schema definition in the specified format.

configType ConfigType

The format of the configuration (XML, JSON, or YAML).

Returns

Schema

A populated Schema object representing the database schema.

Examples

string schemaXml = @"<schema name='myschema'>
    <table name='users'>
        <column name='id' type='Integer' primaryKey='true' />
        <column name='name' type='VarChar' size='100' />
    </table>
</schema>";

using (var m = new Manager())
{
    var schema = m.ReadSchema(schemaXml, ConfigType.Xml);
    Console.WriteLine($"Schema '{schema.Name}' has {schema.Tables.Count} table(s)");
}

Exceptions

CustomViewCodeCompilationException

Thrown when a custom code-based view does not compile properly.

ColumnNotFoundException

Thrown if any referenced columns do not exist in tables.

ReadSchema(Stream, ConfigType)

Reads a schema definition from a stream and returns an in-memory Schema object.

public Schema ReadSchema(Stream stream, ConfigType configType)

Parameters

stream Stream

A readable stream containing the schema definition.

configType ConfigType

The format of the configuration (XML, JSON, or YAML).

Returns

Schema

A populated Schema object representing the database schema.

Examples

using (var fileStream = File.OpenRead("schema.json"))
using (var m = new Manager())
{
    var schema = m.ReadSchema(fileStream, ConfigType.Json);
    Console.WriteLine($"Loaded schema: {schema.Name}");
}

Exceptions

CustomViewCodeCompilationException

Thrown when a custom code-based view does not compile properly.

ColumnNotFoundException

Thrown if any referenced columns do not exist in tables.