我正在使用来自https://github.com/schotime/PetaPoco的相当旧版本的 PetaPoco - 它基本上是支持多主键列的香草。决定是时候升级了。从刚才提到的 schotime 链接中获取最新版本,将其转储到我的项目中,然后立即出现故障,代码结构如下:
class Program
{
public class AggregateObject
{
public int aoId { get; set; }
[PetaPoco.Ignore]
public Object1 o1 { get; set; }
[PetaPoco.Ignore]
public Object2 o2 { get; set; }
}
public class Object1
{
public int o1Id { get; set; }
}
public class Object2
{
public int o2Id { get; set; }
}
static void Main(string[] args)
{
var db = new Database("test");
var test = db.Fetch<AggregateObject, Object1, Object2, AggregateObject>(
(ao, o1, o2) =>
{
ao.o1 = o1;
ao.o2 = o2;
return ao;
},
"SELECT 1 AS aoId, 2 AS o1Id, 3 AS o2Id WHERE 1 <> @start AND 2 <> @end",
new
{
start = 5,
end = 5
});
}
}
引发此错误
No mapping exists from object type <>f__AnonymousType0`2[[System.Int32, mscorlib,
Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089],
System.Data.SqlClient.SqlParameter, System.Data, Version=4.0.0.0, Culture=neutral,
PublicKeyToken=b77a5c561934e089]] to a known managed provider native type.
对于我尝试传入的每个参数(在本例中为 System.Int32、System.Int32)。
通过此方法传入参数的方式是否发生了变化?对错误非常困惑。