CodePaste Logo
New Snippet New Snippet Recent Snippets Recent Snippets My Snippets My Snippets Web Code Search Snippets Search
Sign inor Register
Language: C#

Fluent NHibernate mapping to Oracle 10g

1135 Views
Copy Code Show/Hide Line Numbers
class Program
{
    private static ISessionFactory CreateSessionFactory()
    {
        return Fluently.Configure()
            .Database(
                OracleClientConfiguration
                    .Oracle10
                    .ConnectionString(Properties.Settings.Default.TWTest)
                    .ProxyFactoryFactory(typeof(NHibernate.ByteCode.LinFu.ProxyFactoryFactory)))
            .Mappings(m => m.FluentMappings.AddFromAssembly(Assembly.GetExecutingAssembly()))
            .BuildSessionFactory();
    }
 
    static void Main()
    {
        var allUsers = new List<User>();
 
        var sessionFactory = CreateSessionFactory();
 
        using (var session = sessionFactory.OpenSession())
        {
            using (var xact = session.BeginTransaction())
            {
                allUsers.AddRange(from u in session.Linq<User>() select u);
 
                xact.Commit();
            }
        }
 
        foreach (User u in allUsers)
            Console.WriteLine(u);
    }
}
 
by Andy Sherwood
  January 25, 2010 @ 4:42pm
Tags:

Add a comment


Report Abuse
brought to you by:
West Wind Techologies



If you find this site useful and use it frequently please consider making a donation to support this free service.
Donate