Pau*_*ley 3 c# petapoco .net-4.5
我的代码:
string sql = "SELECT * FROM people where birthday >= @t1 AND birthday <= @t2"
DateTime t1 = DateTime.Parse("01-01-2000");
DateTime t2 = DateTime.Parse("01-01-2001");
var results = db.Fetch<Person>(sql, t1,t2);
Run Code Online (Sandbox Code Playgroud)
此代码产生错误:
additional information: Parameter '@t1' specified but none of the passed arguments have a property with this name (in 'SELECT......
Run Code Online (Sandbox Code Playgroud)
我想知道正确的语法是什么?
我对petapoco并不熟悉,但是通过错误消息,它似乎试图将参数绑定到传递给调用的对象的属性Fetch.如果是这样,请尝试这样的事情:
var results = db.Fetch<Person>(sql, new {t1 = t1, t2 = t2});
Run Code Online (Sandbox Code Playgroud)