//主键用序列
this.Id(p => p.Id, map =>
{
//map.Generator(Generators.Sequence, generatorMapping => generatorMapping.Params("PRODUCT_SQE"));
//上面的代码出错
//
Data.Test.Test.ConformistMappingRegistration:
System.Reflection.TargetParameterCountException : 参数计数不匹配。
map.Generator(Generators.Sequence);
//这句不会出错,但不能指定序列史
});
public CategoryMap()
{
Cache(c =>
{
c.Usage(CacheUsage.ReadWrite);
});
this.Id(c => c.Id, map =>
{
map.Generator(Generators.Identity);
map.Column("CategoryId");
});
this.Property(c => c.Description);
this.Property(c => c.Name);
}
你是指 map.Column("CategoryId")这个名称吗?
map.Column("CategoryId"); 这方法是指定数据库中的列名 并不是指定序列名
看了一下,generatorParameters类型是Object,看看是不是要这样写.
map.Generator(Generators.Sequence, x =>
{
x.Params(new { name = "PRODUCT_SQE" });
});
@zhangweiwen:
OK了,就这种方法,不过
map.Generator(Generators.Sequence, x =>
{
x.Params(new { name = "PRODUCT_SQE" });
});
要改成
map.Generator(Generators.Sequence, x =>
{
x.Params(new { sequence = "SequenceName" });
});
生成的结果为
<id name="ID" column="orderid" type="Int32">
<generator class="sequence">
<param name="sequence">SequenceName</param>
</generator>
</id>