我在 SQL 中有 3 个表...如下所示
现在这映射到以下域对象
public abstract class Case
{
public virtual DateTime Imported { get; set; }
public virtual int Id { get; set; }
}
public class Meeting
{
public virtual int Id { get; set; }
public virtual string Employee { get; set; }
public virtual string LineManager { get; set; }
public virtual Case Case { get; set; }
}
public class SCase : Case
{
public virtual int Id { get; set; }
public virtual string reason { get; set; }
public virtual IList<Meeting> Meeting { get; set; }
}
This works fine when I query it using the following fluent configuration
public class PMap : ClassMap<Case>
{
public PMap()
{
Id(x => x.Id).GeneratedBy.Assigned();
}
}
public class ParentMap : ClassMap<SCase>
{
public ParentMap()
{
Id(x => x.Id);
Map(x => x.reason);
//Map(x => x.Imported);
Join("[Case]", m =>
{
m.Fetch.Join();
m.KeyColumn("Id");
});
}
}
但我不明白为什么它不会保存!当然,如果它可以阅读并知道如何映射事物,那么它必须能够保存它??
我收到以下错误:
{"无法将值 NULL 插入到列 'CaseId',表 'Scratchpad.dbo.SCase;列不允许空值。INSERT 失败。\r\n语句已终止。"}
为什么要插入CaseID
?SCase
当然,既然它是一个连接,它应该从??插入 Id