gaymer gaymer - 17 days ago 8
Vb.net Question

nhibernate VB.NET

I've found examples for configurate NHibernate in command line but in C# and I need it in vb, but I don't find how to do it.
So the question is how to write this in vb:

configuration.Proxy(proxy => proxy.ProxyFactoryFactory<ProxyFactoryFactory>());

configuration.DataBaseIntegration(db =>
{
db.Dialect<MsSql2008Dialect>();
db.ConnectionString = Sql.db;
db.BatchSize = 100;
db.LogSqlInConsole = true;
});


Note: I don't want to do it in XML.

Answer

I succeed!!!

I've 2 working sollutions:

Dim dictionary As New Dictionary(Of String, String)
dictionary.Add("dialect", "NHibernate.Dialect.MsSql2008Dialect")
dictionary.Add("connection.provider", "NHibernate.Connection.DriverConnectionProvider")
dictionary.Add("connection.connection_string", Sql.db)
dictionary.Add("proxyfactory.factory_class", "NHibernate.ByteCode.Castle.ProxyFactoryFactory, NHibernate.ByteCode.Castle")
configuration.AddProperties(dictionary)
configuration.AddAssembly("Core")

and Meta-Knight one (with sub instead of function)

configuration.Proxy(Sub(proxy) proxy.ProxyFactoryFactory(Of ProxyFactoryFactory)())
configuration.DataBaseIntegration( _
                Sub(db)
                    db.Dialect(Of MsSql2008Dialect)()
                    db.ConnectionString = Sql.db
                    db.BatchSize = 100
                    db.LogSqlInConsole = True
                End Sub)
configuration.AddAssembly("Core")

Both Are working well but i did have an other problem with the XML files!

i did this in C# and it was working well:

 <class name="Core.Product, Core" table="Product">
    <class name="Product">

But in VB you HAVE TO add the project name in class definition like this :

<hibernate-mapping xmlns="urn:nhibernate-mapping-2.2">
  <class name="Core.Product, Core">

Hope this will help other people!

Thanks to every one