流利的nHibernate表中没有标识列 [英] Fluent nHibernate no identity column in table
本文介绍了流利的nHibernate表中没有标识列的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
如何使用流畅的NHibernate映射为没有标识列的表指定?
我想要这样的东西:
public sealed class CustomerNewMap: ClassMap< CustomerNew> ;, IMap
{
public CustomerNewMap()
{
WithTable(customers_NEW);
Not.LazyLoad();
Not.Id(); //这是无效的...
Map(x => x.Username);
Map(x => x.Company);
我的意思是没有在数据库中定义的主键(不是在数据库中定义的很多)。
解决方案我找到了答案:
public CustomerNewMap()
{
WithTable(customers_NEW);
Not.LazyLoad();
Id(x => x.Username).GeneratedBy.Assigned();
Map(x => x.Company);
}
How do I specify with fluent NHibernate mapping for a table that doesn't have an identity column?
I want something like this:
public sealed class CustomerNewMap : ClassMap<CustomerNew>, IMap
{
public CustomerNewMap()
{
WithTable("customers_NEW");
Not.LazyLoad();
Not.Id(); // this is invalid...
Map(x => x.Username);
Map(x => x.Company);
}
}
I mean no primary key defined in the database (not much defined in the database).
解决方案 I found the answer to be:
public CustomerNewMap()
{
WithTable("customers_NEW");
Not.LazyLoad();
Id(x => x.Username).GeneratedBy.Assigned();
Map(x => x.Company);
}
这篇关于流利的nHibernate表中没有标识列的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文