我还是MVC和dapper ORM的新手。 假设我使用dapper进行MVC,当我尝试构建解决方案时,它显示消息: ' SqlConnection不包含'查询'的定义。没有扩展方法'查询'接受类型' SqlConnection'。
的第一个参数这是代码:
using System.Collections.Generic;
using System.Data.SqlClient;
public string Connectionstring = @"Data Source = KL - PT - 049\sqlexpress;Initial Catalog = Record; Integrated Security = True";
public IEnumerable<Customer> GetCustomers()
{
using (SqlConnection conn = new SqlConnection(Connectionstring))
{
conn.Open();
var customer = conn.**Query**<Customer>("Select * from Customer");
return customer;
}
我的问题是:如果我使用这种方式,上面的查询是否应该没问题?既然我已经使用了data.sqlClient引用?