private static void ConfigValidator(Configuration config) { var configuration = new NHibernate.Validator.Cfg.Loquacious.FluentConfiguration(); configuration .SetDefaultValidatorMode(ValidatorMode.OverrideAttributeWithExternal) .Register(Assembly.Load("Blog.Repository, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null") .ValidationDefinitions()) .IntegrateWithNHibernate .ApplyingDDLConstraints() .And .RegisteringListeners(); var validatorEngine = new ValidatorEngine(); validatorEngine.Configure(configuration); new BasicSharedEngineProvider(validatorEngine, config).UseMe(); }
private static void ConfigureNhibernate(Configuration config) { var provider = new NHibernateSharedEngineProvider(); NHibernate.Validator.Cfg.Environment.SharedEngineProvider = provider; var nhvConfiguration = new NHibernate.Validator.Cfg.Loquacious.FluentConfiguration(); nhvConfiguration .SetDefaultValidatorMode(ValidatorMode.OverrideExternalWithAttribute) .Register(Assembly.GetExecutingAssembly().ValidationDefinitions()) .IntegrateWithNHibernate .AvoidingDDLConstraints() .RegisteringListeners(); ValidatorEngine validatorEngine = NHibernate.Validator.Cfg.Environment.SharedEngineProvider.GetEngine(); validatorEngine.Configure(nhvConfiguration); ValidatorInitializer.Initialize(config, validatorEngine); config.SetProperty("current_session_context_class", "thread_static"); //fix bug: http://stackoverflow.com/questions/2361730/assertionfailure-null-identifier-fluentnh-sqlserverce config.SetProperty("connection.release_mode", "on_close"); //// delete the existing db on each run //if (File.Exists(DbFile)) // File.Delete(DbFile); if (!File.Exists(HttpContext.Current.Server.MapPath(DbFile.Replace(@"|DataDirectory|", @"~/App_Data/")))) { SqlCEDbHelper.CreateDatabaseFile(DbFile); // this NHibernate tool takes a configuration (with mapping info in) // and exports a database schema from it new SchemaExport(config) .Create(false, true); } }