Why is currency an entity? wouldn't this also be a value type? after
all 1 instance of US Dollar wouldn't be unique from a second instance
would it?
In any case you should be able to map your Money object using the
standard Component mapping.

I didn't think [public readonly CurrencyObj Currency{ get; set; } ]
would work. readonly applies to fields, not properties. you could
configure the object this way though.
public class Money
{
      public CurrencyObj Currency{ get; private set; }
      public decimal Amount{ get; private set; }

      //for nhibernate
      protected Money()
      {
      }

      public Money(CurrencyObj currency, decimal amount)
      {
            Currency = currency;
            Amount = amount;
      }
}

On Jan 28, 1:38 pm, [email protected] wrote:
> All,
>
> I have the a Money "value type" which has a CurrencyObj "entity" as a  
> property:
>
> public class Money
> {
> public readonly CurrencyObj Currency{ get; set; }
> public readonly decimal Amount{ get; set; }
>
> public Money(CurrencyObj currency, decimal amount)
> {
> this.Currency = currency;
> this.Amount = amount;
>
> }
> }
>
> public class CurrencyObj
> {
> public readonly int Id;
>
> public readonly string IsoAlphaCode { get; set; }
>
> public readonly string Name { get; set; }
>
> public Currency(int id, string isoAlphaCode, string name)
> {
> this.Id = id;
> this.IsoAlphaCode = isoAlphaCode;
> this.Name = name;
>
> }
> }
>
> The Money.Amount property values is in one table whereas the Money.Currency  
> property values are in another.
>
> I want to be able to map the Money value type using the constructor with  
> arguments.
> Can this be done using ICompositeUserType - Im thinking not as all values  
> would need to be in the same table?
> Is there another way?
>
> Cheers
> Billy Stack

-- 
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.

Reply via email to