我正在使用夏普體系結構,並且在實體中使用了多個值對象。下面是一個明顯簡單的例子:使用fluent-nhibernate是否可以在實體內自動映射值對象?
public class Person : Entity
{
protected Person(){}
public Person(string personName)
{
this.PersonName = personName;
}
public virtual string PersonName { get; protected set;}
public virtual StreetAddress MailingAddress { get; set; }
}
public class StreetAddress : ValueObject
{
protected StreetAddress(){}
public StreetAddress(string address1, string address2, string city, string state, string postalCode, string country)
{
this.Address1 = address1;
this.Address2 = address2;
this.City = city;
this.State = state;
this.PostalCode = postalCode;
this.Country = country;
}
public virtual string Address1 { get; protected set; }
public virtual string Address2 { get; protected set; }
public virtual string City { get; protected set; }
public virtual string State { get; protected set; }
public virtual string PostalCode { get; protected set; }
public virtual string Country { get; protected set; }
}
這當然拋出:
An association from the table Person refers to an unmapped class: Project.Domain.StreetAddress因爲所述AutoPersistenceModelGenerator僅包括與類型類IEntityWithTypedId <>。尚不清楚夏普體系結構如何預期這種共同條件得以實施。這是否必須用bazillion覆蓋來處理?