尖锐的架构忽略了我的公式映射
我遇到一个问题,Sharp Architecture 将正确映射我在 IAutoMappingOverride
类中设置的所有内容(Formula
除外)。这些被简单地忽略,因此当我尝试查询数据库时,我得到了 SQL 的无效标识符
。
// NUnit setup
public virtual void SetUp()
{
configuration = NHibernateSession.Init(
new SimpleSessionStorage(),
RepositoryTestsHelper.GetMappingAssemblies(),
new AutoPersistenceModelGenerator().Generate(),
null,
null,
null,
FluentConfigurer.TestConfigurer.Contracts);
new FluentConfigurer(configuration)
.ConfigureNHibernateValidator()
.ConfigureAuditListeners();
}
public AutoPersistenceModel Generate()
{
return AutoMap.AssemblyOf<Contrato>(new AutomappingConfiguration())
.Conventions.Setup(GetConventions())
.IgnoreBase<Entity>()
.IgnoreBase(typeof(EntityWithTypedId<>))
.UseOverridesFromAssemblyOf<EmployeeMap>();
}
// My override.
public class EmployeeMap : IAutoMappingOverride<Employee>
{
public void Override(AutoMapping<Employee> mapping)
{
// This works...
mapping.Id(x => x.Id, "ID_EMPLOYEE");
// This is ignored...
mapping.Map(x => x.Name).Formula("UPPER(LTRIM(RTRIM(FIRST_NAME || ' ' || LAST_NAME)))");
}
}
有什么想法吗?
I'm having a problem where Sharp Architecture will correctly map everything I have setup in my IAutoMappingOverride
classes, except for Formula
. These get simply ignored and thus I get SQL's invalid identifier
when trying to query the database.
// NUnit setup
public virtual void SetUp()
{
configuration = NHibernateSession.Init(
new SimpleSessionStorage(),
RepositoryTestsHelper.GetMappingAssemblies(),
new AutoPersistenceModelGenerator().Generate(),
null,
null,
null,
FluentConfigurer.TestConfigurer.Contracts);
new FluentConfigurer(configuration)
.ConfigureNHibernateValidator()
.ConfigureAuditListeners();
}
public AutoPersistenceModel Generate()
{
return AutoMap.AssemblyOf<Contrato>(new AutomappingConfiguration())
.Conventions.Setup(GetConventions())
.IgnoreBase<Entity>()
.IgnoreBase(typeof(EntityWithTypedId<>))
.UseOverridesFromAssemblyOf<EmployeeMap>();
}
// My override.
public class EmployeeMap : IAutoMappingOverride<Employee>
{
public void Override(AutoMapping<Employee> mapping)
{
// This works...
mapping.Id(x => x.Id, "ID_EMPLOYEE");
// This is ignored...
mapping.Map(x => x.Name).Formula("UPPER(LTRIM(RTRIM(FIRST_NAME || ' ' || LAST_NAME)))");
}
}
Any ideas?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
这不是 Sharp Architecture 的问题,而是 Fluent Nhibernate 的问题。您使用什么版本的 FNH?
This is not an issue with Sharp Architecture, it is an issue with Fluent Nhibernate. What version of FNH are you using?
我确认这是
Fluent NHibernate
(1.2.0.694) 的问题。以前,列名映射优先于 FluentMappingOverrides,但是最新的将优先于《公约》。我修改了我的
排除包含公式映射的命名空间的约定
现在好了。
I confirmed this is an issue with
Fluent NHibernate
(1.2.0.694). Previously, a column-name mapping would give precedence to the FluentMappingOverrides, but thelatest would give precedence to the Convention. I modified my
convention to exclude the namespaces that contain the formula mappings
and now it's Ok.