我正在尝试加载引用,但在这种情况下,来自同一个表的两个引用它不起作用
[Required]
public DateTime CreatedOn { get; set; }
public DateTime? ModifiedOn { get; set; }
[References(typeof(Employee))]
public int? CreatedById { get; set; }
[Reference]
public Employee CreatedBy { get; set; }
[References(typeof(Employee))]
public int? ModifiedById { get; set; }
[Reference]
public Employee ModifiedBy { get; set; }
正如您在上面所看到的,我以正确的方式做了它作为ORMLite的文档:https://github.com/ServiceStack/ServiceStack.OrmLite
即使属性ModifiedById和CreatedById具有值,它也不会加载属性:ModifieldBy和CreatedBy . 我尝试使用必填字段并且它有效,但是当我尝试使用int时? nulable它不起作用 .
你可以在下面的图片中看到我在ModifiedById列中有一个值为"5"的记录,所以我的方法的Loadreferences应该得到列:ModifiedBy(加载了Employee对象)它在其他情况下工作,而不是在这种情况下 .
1 回答
我添加了一个通过测试,用可空的
int?
Ids in this commit测试多个自引用:使用的类型:
删除并重新创建表:
创建具有多个自引用的记录:
保存并测试填充的行:
加载自引用行: