我正在使用来自https://github.com/schotime/PetaPoco的相当旧版本的PetaPoco - 它基本上是vanilla,支持多主键列。决定是时候升级了。从上面提到的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)。
通过此方法传递参数的方式有什么变化吗?对错误非常困惑。