Hi
Does anyone have a working example where they have either used a
Validator attribute e.g. [NotNull] on a Domain Object property or a
new ValidationDef for that property, and are using Fluent mappings and
have seen via a SchemaExport that the property is defined a NOT NULL
in the DLL?
I'm missing some wiring somewhere and dont know where. Here's my code:
var nhvConfiguration = new FluentConfiguration
();
nhvConfiguration
.SetDefaultValidatorMode(ValidatorMode.UseExternal)
.Register<MyObjectValidation, MyObject>()
.Register(Assembly.Load("MyDomainAssembly")
.ValidationDefinitions())
.IntegrateWithNHibernate
.ApplyingDDLConstraints()
.And
.RegisteringListeners();
var nhibernateConfig = new Configuration().Configure();
var validatorEngine = new ValidatorEngine();
validatorEngine.Configure(nhvConfiguration);
nhibernateConfig.Initialize(validatorEngine);
ConfigureDatabaseAndMappings()
.ExposeConfiguration(cfg => new
SchemaExport(cfg).Create(true,
true))
.BuildSessionFactory();
protected static FluentConfiguration ConfigureDatabaseAndMappings()
{
return Fluently.Configure()
.Database(
MsSqlConfiguration.MsSql2005.ConnectionString(c =>
c.FromConnectionStringWithKey("MyDb"))
.ShowSql())
.Mappings(m =>
m.FluentMappings.AddFromAssemblyOf<MediaDescriptionMap>()
.Conventions.AddFromAssemblyOf<WellNamedForeignKeyColumnConvention>
());
}
--
You received this message because you are subscribed to the Google Groups
"nhusers" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to
[email protected].
For more options, visit this group at
http://groups.google.com/group/nhusers?hl=en.