Hi

I was wondering if there was some way to query the schema of the
database using NHibernate?

The only thing I can think of at this point is to take the raw
IDbConnection from the NHibernate.ISession object and use raw ADO.NET.
What I've got at the moment is the following code which works to some
extent. For instance, I can get table names and column names but not
which columns are primary keys, and data types are provider specific
(e.g. "vchar" in SqlServer is 129 in OleDb). This is going to cause a
nightmare in provider-dependent code and I would much rather not limit
the app to a single provider.

I'm hoping that this complexity has already been abstracted away in
NHibernate or maybe some other framework?

Any help you can give would be greatly appreciated!

Thanks in advance

James

public static DataTable GetSchemaInfo(ISession session, string
collectionName, string[] restrictions = null)
{
var dbConnection = session.Connection as DbConnection;

if ( dbConnection == null )
return null;

if (restrictions == null)
return dbConnection.GetSchema( collectionName );

return dbConnection.GetSchema( collectionName, restrictions );
}

-- 
You received this message because you are subscribed to the Google Groups 
"nhusers" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/nhusers?hl=en.

Reply via email to