我正在尝试使用Npoco,但在使用 FetchOneToMany 时遇到了一些问题
我有一个将 2 个表连接在一起的 sql 语句,并输出所有列。
[TableName("TableA")]
[PrimaryKey("Id")]
public class TableA
{
public int Id { get; set; }
public DateTime EffectiveDate { get; set; }
public IList<TableB> TableBs { get; set; }
}
[TableName("TableB")]
[PrimaryKey("TableBId")]
public class TableB
{
public int TableBId { get; set; }
public int SomeNumber { get; set; }
public int Id { get; set; } // TableA id
}
Func<TableA, object> func1 = (x) => x.Id;
Func<TableB, object> func2 = (x) => x.Id;
var test = RelationExtensions.FetchOneToMany<AdminFeeBandGroup, AdminFeeBand>(unitOfWork.Db, func1,func2,sql, 1,1,"10-18-2012","10-22-2012");
我在我的真实查询中传递了 4 个参数。我得到了一个结果,并且TableBs property
被填满并且看起来不错。然而,EffectiveDate 出于某种原因未填写,它是默认的 C# 时间。
我错过了什么?
编辑
这就是我的查询
SELECT TableA.Id, TableA.EffectiveDate, TableB.TableBId, TableB.SomeNumber
FROM TableA INNER JOIN
TableB ON TableA.Id = TableB.Id
WHERE (TableA.EffectiveDate = @0)
Func<TableA, object> func1 = (x) => x.Id;
Func<TableB, object> func2 = (x) => x.Id;
var test = RelationExtensions.FetchOneToMany<AdminFeeBandGroup, AdminFeeBand>(unitOfWork.Db, func1,func2,sql, "10-18-2012");