作者热门文章
- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我正在使用 Sharp 架构,并且在许多情况下都在实体中使用了值对象。这是一个明显的简单示例:
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<> 的类。目前尚不清楚 Sharp Architecture 期望如何实现这种常见条件。这是否必须通过无数次覆盖来处理?
最佳答案
您可以将 AutoPersistenceModelGenerator 中的 GetSetup() 方法更改为:
private Action<AutoMappingExpressions> GetSetup()
{
return c =>
{
c.IsComponentType = type => type.BaseType == typeof (ValueObject);
};
}
我将尝试获取我看到的涵盖此帖子的博文以获得信用。
关于fluent-nhibernate - 使用 fluent-nhibernate 是否可以在实体内自动映射值对象?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/3074086/
因此,我的flutter应用程序运行正常,但是我想对其进行一些更改。 我要执行的第一个更改是创建一个水平滚动窗口小部件,该窗口小部件的图像可以单击以更改工作站。 但是要做到这一点,我首先需要将两个小部
如何在 Bootstrap 模态的主体内设置 div 样式?这是我的模型: text ') .okBtn('ok') .open();">Open Model 我的CSS: @M
我有一个简单的触发器,它在 SQL Fiddle 上运行,但它不允许我将 INSERT STATEMENT 移动到触发器的主体内。 my code on sqlFiddle我只是想移动这条线 INSE
我是一名优秀的程序员,十分优秀!