Hi
Thanks for the bug report, I'll put that on my todo list of fixes. In the
mean time you should be able to ignore that property using the
IgnoreProperty Method on ForTypesThatDeriveFrom<> Method off
persistancebase.

eg

model.ForTypesThatDeriveFrom<Company>(m => m.IgnoreProperty(p => p.MyDate));

Does that make sense.

Andy

On Tue, Jan 20, 2009 at 3:52 PM, <s.lov...@gmail.com> wrote:

>
> Hello all,
>
> I have an entity class that contains a readonly property of type
> DateTime?.  I don't want the property to be mapped as it doesn't exist
> on the DB (it's a calculated field).  AutoMapper is supposed (I think)
> to ignore properties without a setter, but because this property is of
> type Nullable<> it tries to map it.
>
> The problem is in AutoMapColumn.MapsProperty:
> -----
>        public bool MapsProperty(PropertyInfo property)
>        {
>            if (HasExplicitTypeConvention(property))
>                return true;
>
>            if (property.CanWrite)
>                return property.PropertyType.Namespace == "System";
>
>            return false;
>        }
> ----
>
> Because by default the conventions contain the
> IgnoreNullableTypeConvention, the first 'if' above causes the property
> to be mapped.  Obviously, I could add "if (!property.CanWrite) return
> false;" to the start of this method, but I'm not quite sure I
> understand the thinking behind IgnoreNullableTypeConvention.  It
> sounds like it should prevent nullable properties from being mapped,
> but stepping through the code they do still get mapped (the AlterMap
> method is empty, but that doesn't stop the xmlelement being created).
>
> I know you are busy looking at reworking the AutoMapping, but could
> anyone shed some light on this?  Is it a bug?  If it is, I'm more than
> happy to supply a patch and tests.
>
> Or would it just be easier to create a [DoNotMap] attribute and set a
> convention to ignore those properties?
>
> Apologies for the length of this question.
>
> Thanks in advance,
> Simon.
>
> >
>


-- 
=================
I-nnovate Software - Bespoke Software Development, uk wirral.
http://www.i-nnovate.net

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"Fluent NHibernate" group.
To post to this group, send email to fluent-nhibernate@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