public static class MiniSQLHelper{
public static object SqlQuerySingleOrDefault<TParam>(this IDbConnection cnn, string query, TParam param)
where TParam : class
{
//......
}
}
using (var conn = Connection){
var result = conn.SqlQuerySingleOrDefault("select @v ", new { v = 1 }); /*Success*/
}
public static class MiniSQLHelper{
public static T SqlQuerySingleOrDefault<T, TParam>(this IDbConnection cnn, string query, TParam param)
where TParam : class
{
//......
}
}
using (var conn = Connection){
var result = conn.SqlQuerySingleOrDefault<int>("select @v ", new { v = 1 });/*CS1503 C# Argument 3: cannot convert from to 'int'*/
}
我如何实现云计算两个通用参数,一个用于规范,一个用于类型推断。