Part I : NHibernate Configuration
Part II : NHibernate Fluent Configuration
This will be, probably, the last way, to configure the session-factory, available in NH-Core.
var configure = new Configuration();
c.UseMinimalPuts = true;
c.DefaultExpiration = 15;
c.RegionsPrefix = "xyz";
p.Validation = false;
m.DefaultCatalog = "MyCatalog";
m.DefaultSchema = "MySche";
db.KeywordsAutoImport = Hbm2DDLKeyWords.AutoQuote;
db.BatchSize = 15;
db.ConnectionReleaseMode = ConnectionReleaseMode.AfterTransaction;
db.IsolationLevel = IsolationLevel.ReadCommitted;
db.ConnectionString = "The connection string";
db.AutoCommentSql = true;
db.PrepareCommands = true;
db.Timeout = 10;
db.MaximumDepthOfOuterJoinFetching = 11;
db.HqlToSqlSubstitutions = "true 1, false 0, yes 'Y', no 'N'";
db.SchemaAction = SchemaAutoAction.Validate;
Perhaps the configuration through lambda is less fluent but more clear, easy to use and R# friendly.
With NH3.0.0, you have five or six ways to configure the session-factory. The advantage of the two added in NH3 is that both are strongly typed. The fluent-configuration and the lambda-configuration was implemented using extensions-methods; probably we will extend the configuration to have a fashion way to integrate some other project (I’m thinking in some extensions in NHV, for example).
All available configuration-ways are allowing merge/override with the previous configuration that mean you can do something like:
var configuration = new Configuration();
p.Validation = false;
- configure through app.config
- override/merge with a hibernate.cfg.xml file
- override/merge the proxy configuration with lambda
- add resources from a namespace in one assembly
- override/merge the cache with the fluent-configuration
What’s next ?
After some needed thinking, the next step is the programmatic configuration of the mapping.
What is the different between this approach and FluentNhibernate configuration approach?
I don't understand what you mean ?ReplyDelete
Can you explain your question a little bit more ?
I believe he's referring to this: http://wiki.fluentnhibernate.org/show/DatabaseConfigurationReplyDelete
I didn't have review the code behind the implementation of FNH. From the view of the wiki page there are various difference. If @ryzam mean the same of James what I don't understand is the target a of comparison between NH configuration and FNH configuration.ReplyDelete
They have the same goal. Why reinvent when you can improve?ReplyDelete
I think the same.
Perhaps for the same reason we have NH and EF, Spring and Windsor and StructureMap and AutoFact and Unity and LinFu and Funq, Log4Net and NLog and LAB, LinFu-AOP and Castle-AOP and Spring-AOP, J# and C# and VB.NET and Delphi.NET, NUnit and xUnit and MbUnit. Perhaps all are wheel but with different point of view and different structure, even if the goal of the wheel is the same.
As you saw with nhibernatelambda, the integration had a different story.
I mean it the same what James had informed, it is about fluentnhibernate project. Just confuse with the one in NHibernate core.
NHibernate.Cfg.Configuration not in NHibernate 126.96.36.19900ReplyDelete