You want a property
convention<http://wiki.fluentnhibernate.org/show/Conventions>to set
everything to null, then you have a few options for how to handle the
not null ones.
something like:
public class NullPropertyConvention : IPropertyConvention
{
public bool Accept(IProperty target)
{
return true;
}
public void Apply(IProperty target)
{
target.Nullable();
}
}
then for the not nulls, you can either override them on the
AutoPersistenceModel<http://wiki.fluentnhibernate.org/show/AutoMappingAlteringEntities>
:
.ForTypesThatDeriveFrom<MyEntity>(m =>
m.Map(x => x.MyProperty)
.Not.Nullable());
or you can use an automapping
override<http://wiki.fluentnhibernate.org/show/AutoMappingOverrides>
:
public class PersonMappingOverride : IAutoMappingOverride<Person>
{
public void Override(AutoMap<Person> mapping)
{
mapping.Map(x => x.MyProperty)
.Not.Nullable();
}
}
On Wed, Mar 25, 2009 at 2:33 PM, Anders <[email protected]> wrote:
>
> Hi,
>
> I want almost all of my properties to be "non-null", and instead
> override some specific properties that can be null. How do I do this
> using AutoPersistenceModel?
>
> Thanks
> >
>
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"Fluent NHibernate" 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/fluent-nhibernate?hl=en
-~----------~----~----~----~------~----~------~--~---