0
我想用fluentnhibernate映射接口和具體類。用FluentNHibernate映射接口和具體類
這裏是我的接口/類:
public interface IUser
{
int Id { get; set; }
}
public class User: IUser
{
public int Id { get; set; }
public string Name { get; set; }
public string Password { get; set; }
}
這裏是我的映射文件:
public class IUserMap: ClassMap
{
public IUserMap()
{
Table("User");
Id(u => u.Id)
.Column("Id")
.GeneratedBy.Native();
}
}
public class UserMap: SubclassMap
{
public UserMap()
{
Map(u => u.Name);
Map(u => u.Password);
}
}
,我得到這個錯誤:
could not execute query [ SELECT this_.Object_id as Id3_0_, this_.Name as Name4_0_, this_.Password as Password4_0_ FROM "User" this_ inner join User this_1_ on this_.Object_id=this_1_.Id WHERE this_.Name = @p0 ] Positional parameters: #0>test [SQL: SELECT this_.Object_id as Id3_0_, this_.Name as Name4_0_, this_.Password as Password4_0_ FROM "User" this_ inner join User this_1_ on this_.Object_id=this_1_.Id WHERE this_.Name = @p0]
...
通知「this_.Object_id」列是l ooking ...這不是我的ID列,但我不能指定一個Id(「my_id_column」);在子類地圖
我做錯了什麼?
將KeyColumn(「Id」)添加到我的子SubclassMap工作。我也會爲object_id問題打開一張票。 謝謝,詹姆斯! –
2009-11-05 13:12:32