【发布时间】:2014-12-07 08:45:40
【问题描述】:
这是我第一次使用 Dapper.Contrib(来自 Nuget 的最新版本),这是一个奇怪的情况:
using (SqlConnection cn = new SqlConnection(connectionString))
{
cn.Open();
var product = cn.Get<Product>(1);
}
在 SqlMapperExtensions 上,它会引发错误 Invalid object name 'Products':
public static T Get<T>(this IDbConnection connection,
dynamic id,
IDbTransaction transaction = null,
int? commandTimeout = null) where T : class
{
var type = typeof(T);
string sql;
if (!GetQueries.TryGetValue(type.TypeHandle, out sql))
}
数据库接收到的命令select * from Products where Id = @id是错误的。
为什么要在 Product 后面加上 s?
我尝试过使用其他表并得到相同的结果。
【问题讨论】: