The auto-quote and auto import KeyWords features are now available in NHibernate but only for those dialects are providing an implementation of IDataBaseSchema.
If the NHibernate’s dialect, for your favorite RDBMS, does not provide an implementation of IDataBaseSchema, what can you do ?
First of all you need an easy way to know some “internals” of your DataProvider/RDBMS. The code to extract all information you are needing to implement a IDataBaseSchema is:
internal class Program
{
private static void Main(string[] args)
{
// Extract metadata for Oracle
CreateMetadataXml("System.Data.OracleClient", "User Id=NH; Password=nh");
// Extract metadata for MsSQL
CreateMetadataXml("System.Data.SqlClient", @"Data Source=localhost\SQLEXPRESS;Initial Catalog=NHTEST;Integrated Security=True");
Console.WriteLine("Work done!");
Console.ReadLine();
}
private static void CreateMetadataXml(string providerName, string connectionString)
{
DbProviderFactory factory = DbProviderFactories.GetFactory(providerName);
using (DbConnection conn = factory.CreateConnection())
{
try
{
conn.ConnectionString = connectionString;
conn.Open();
//Get MetaDataCollections and write to an XML file.
//This is equivalent to GetSchema()
DataTable dtMetadata = conn.GetSchema(DbMetaDataCollectionNames.MetaDataCollections);
dtMetadata.WriteXml(providerName + "_MetaDataCollections.xml");
//Get Restrictions and write to an XML file.
DataTable dtRestrictions = conn.GetSchema(DbMetaDataCollectionNames.Restrictions);
dtRestrictions.WriteXml(providerName + "_Restrictions.xml");
//Get DataSourceInformation and write to an XML file.
DataTable dtDataSrcInfo = conn.GetSchema(DbMetaDataCollectionNames.DataSourceInformation);
dtDataSrcInfo.WriteXml(providerName + "_DataSourceInformation.xml");
//data types and write to an XML file.
DataTable dtDataTypes = conn.GetSchema(DbMetaDataCollectionNames.DataTypes);
dtDataTypes.WriteXml(providerName + "_DataTypes.xml");
//Get ReservedWords and write to an XML file.
DataTable dtReservedWords = conn.GetSchema(DbMetaDataCollectionNames.ReservedWords);
dtReservedWords.WriteXml(providerName + "_ReservedWords.xml");
}
catch (Exception ex)
{
Console.WriteLine(ex.Message);
Console.WriteLine(ex.StackTrace);
}
}
}
}
The code above will create an XML file for each “matter” involved with IDataBaseSchema implementation.
I don’t want to deep in details because each RDBMS may have different info so the only things I can tell you are:
Create a new JIRA ticket as:
Thanks.