Not sure why you need a Nullable<> here, as even though your class may be
represented as a component it's still a reference type and thus implicitly
nullable anyway.

On Thu, Jan 14, 2010 at 6:18 PM, playtime <playtime...@googlemail.com>wrote:

> Well, it works transparently with all the built-in value types such as
> int, decimal, DateTime etc.
>
> I also have no issues mapping my value type, CurrencyAmount, when it
> is mandatory.
>
> I cannot find the correct way to map, CurrencyAmount when it's
> Nullable<CurrencyAmount>. E.g.:
>
> public struct CurrencyAmount : IComparable<CurrencyAmount>,
> IEquatable<CurrencyAmount>
> {
>        public CurrencyAmount(decimal amount, Currency currency)
> {    //etc...    }
>        private decimal _Amount;
>        public decimal Amount     {       get { return
> _Amount; }      }
>        private Currency _Currency;
>        public Currency Currency    {     get { return
> _Currency; }   }
>       //etc...
> }
>
> public class MyEntity
> {
>        private CurrencyAmount _Value;
>        public CurrencyAmount Value { get { return _Value; }    }
>        private CurrencyAmount? _NullableValue;
>        public CurrencyAmount? NullableValue  { get { return
> _NullableValue; }     }
> }
>
> public class MyEntityMap : ClassMap<MyEntity>
> {
>   public MyEntityMap ()
>   {
>            Component(m => m.Value, CurrencyAmountComponent.Map
> ("Value")); //Works fine
>
>            //Complains about not finding backing field "_Amount"
>            Component(m => m.NullableValue, CurrencyAmountComponent.Map
> ("NullableValue"));
>   }
> }
>
> public class CurrencyAmountComponent
> {
>    public static Action<ComponentPart<CurrencyAmount>> Map(string
> columnPrefix, bool nullable)
>    {
>        return c =>
>        {
>                c.Map(x => x.Amount, columnPrefix + "Amount");
>                c.References(x => x.Currency, columnPrefix +
> "Currency");
>        };
>    }
> }
>
> So. rather stumped at the moment.
>
> --
> 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<fluent-nhibernate%2bunsubscr...@googlegroups.com>
> .
> For more options, visit this group at
> http://groups.google.com/group/fluent-nhibernate?hl=en.
>
>
>
>
--
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