Sharp Architecture inheritance problem -
my problem inheritance.
i have actor class
using system.collections.generic; using sharparch.core; using sharparch.core.domainmodel;
namespace proteria.net.common.domain { public class actor : entity { public actor() { init(); }
private void init() { addresses = new list<address>(); } public virtual account account { get; set; } public virtual string number { get; set; } public virtual string telephone { get; set; } public virtual string fax { get; set; } public virtual string email { get; set; } public virtual string idnumber { get; set; } public virtual countrycode country { get; set; } public virtual ilist<address> addresses { get; set; } public virtual void addaddress(address address) { address.actor = this; addresses.add(address); } }
}
and 2 derived classes,
using system.collections.generic; using sharparch.core; using sharparch.core.domainmodel;
namespace proteria.net.common.domain { public class company : actor { private string _companyname;
protected company() { init(); } public company(string companyname) : this() { check.require(!string.isnullorempty(companyname) && companyname.trim() != string.empty, "company name must provided"); _companyname = companyname; } private void init() { employees = new list<employee>(); } public virtual account account { get; set; } public virtual string eorinumber { get; set; } [domainsignature] public virtual string companyname { { return _companyname; } protected set { _companyname = value; } } public virtual companyncts companyncts {get;set;} public virtual ilist<employee> employees { get; set; } public virtual void addemployee(employee employee) { employee.company = this; employees.add(employee); } }
} and
using sharparch.core; using sharparch.core.domainmodel;
namespace proteria.net.common.domain { public class contact : actor { private string _forename;
protected contact() { } public contact(string forename) : this() { check.require(!string.isnullorempty(forename) && forename.trim() != string.empty, "contact first name must provided"); _forename = forename; } public virtual account account { get; set; } [domainsignature] public virtual string forename { { return _forename; } protected set { _forename = value; } } public virtual string surname { get; set; } public virtual string mobile { get; set; } }
}
when call
actor actor = _actorrepository.get(id);
it works fine. , correct type of actor -> company or contact
the problem when embed actor class class below.
using system; using system.collections.generic; using nhibernate.validator.constraints; using sharparch.core; using sharparch.core.domainmodel;
namespace proteria.net.common.domain { public class article : entity { private string _number;
public article(string number, account account) : this() { check.require(!string.isnullorempty(number) && number.trim() != string.empty, "articlenumber must provided"); check.require((account != null), "account must provided"); _account = account; _number = number; } protected article() { init(); } private void init() { descriptions = new list<articledescription>(); unitprices = new list<articleprice>(); } private account _account; public virtual account account { { return _account; } set { _account = value; } } [domainsignature] [notnull, notempty] public virtual string number { { return _number; } protected set { _number = value; } } public virtual actor sender { get; set; } public virtual currencycode currencycode { get; set; } [notnull] public virtual languagecode languagecode { get; set; } public virtual articlencts articlencts { get; set; } public virtual articlede articlede { get; set; } public virtual articlese articlese { get; set; } public virtual articleno articleno { get; set; } public virtual countrycode countrycode { get; set; } public virtual hscode hscode { get; set; } public virtual double grossweight { get; set; } public virtual double netweight { get; set; } public virtual string exportcode { get; set; } public virtual string importcode { get; set; } public virtual string tariccode { get; set; } public virtual ilist<articledescription> descriptions { get; set; } public virtual ilist<articleprice> unitprices { get; set; } public virtual void addarticledescription(articledescription articledescription) { descriptions.add(articledescription); } public virtual void addarticleprice(articleprice articleprice) { unitprices.add(articleprice); } }
}
then if call
article article = _articlerepository.get(articleid);
article.sender won't mapped correctly, in base type, not derived type.
i not sure if doing wrong.
Comments
Post a Comment