How to map an object to a Schema
I currently have a website with one database and two applications running underneath it. To separate the tables for each app I have created a schema for each app. I'm now adding a third app and would like to use native NHibernate vs. Castle Active Record as I have in the past.
As part of my efforts I'm using Fluent NHibernate for the mappings but when I run my queries they are going against the DBO schema. Can I adjust this via the Mapping class or am I doing something wrong with my query? I know for Castle Active Record that I could set the schema within an Attribute on the class.
So to kill you with information, my schemas are DBO, Sports, and now Tournament.
Inside my app I'm running this query:
using (var session = sessionFactory.OpenSession())
{
var query = session.CreateQuery("select t.Id, t.Name from Team t").List();
List<Team> teams = new List<Teams>();
foreach (var team in query)
{
Teams.Add(team as Team);
}
}
And when I watch Query analyzer the query looks good minus the Schema is wrong.
Thanks for your help.
-eric
2 Posted by Eric Neunaber on 12 Jul, 2010 03:32 AM
I stepped away from the computer and came back to take a fresh look. I found the documentation confusing but when I looked at the FAQ's my answer was right on top.
http://wiki.fluentnhibernate.org/Using_multiple_or_different_schemas
public class PersonMap : ClassMap
{ public PersonMap() {
} }