[Serializable]
    [AttributeUsage(AttributeTargets.Property)]
    public class DefaultToNowOnInsertAttribute : Attribute
    {
    }

public class DefaultToNowOnInsertConvention :
AttributePropertyConvention<DefaultToNowOnInsertAttribute>
    {
        protected override void Apply(DefaultToNowOnInsertAttribute
attribute, IPropertyInstance instance)
        {
            instance.Not.Nullable();
            instance.Default("getdate()");
            instance.Generated.Insert();
        }
    }
....

[DefaultToNowOnInsert]
public virtual DateTime LastUpdated  {get; set;}

....

On Mar 16, 5:08 pm, "Rob#" <robie...@gmail.com> wrote:
> Hi,
>
> I have CreateDate property in all of my entities and I would like the
> SQL server to insert the value for them.
>
> public class ContactMappingOverride : IAutoMappingOverride<Contact>
>     {
>         public void Override(AutoMapping<Contact> mapping)
>         {
>             mapping.Map(c => c.CreateDate).ReadOnly();
>         }
>     }
>
>  I know how to make them readonly overrides using Fluent mapping (code
> above)  but not sure how I could do it by auto mapping.  how would I
> do it using property convention?  Many thanks.

-- 
You received this message because you are subscribed to the Google Groups 
"Fluent NHibernate" group.
To post to this group, send email to fluent-nhibern...@googlegroups.com.
To unsubscribe from this group, send email to 
fluent-nhibernate+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/fluent-nhibernate?hl=en.

Reply via email to