簡體   English   中英

System.Data.SqlClient.SqlConnection不包含帶有dapper和c#的Query的定義

[英]System.Data.SqlClient.SqlConnection does not contain a definition for Query with dapper and c#

編譯時的以下代碼給出了以下錯誤消息:

'System.Data.SqlClient.SqlConnection'不包含'Query'的定義,並且沒有擴展方法'Query'接受類型為'System.Data.SqlClient.SqlConnection'的第一個參數'(你是否缺少using指令)或匯編參考?)

我使用nuget包裝器添加了Dapper。

有任何想法嗎? 謝謝,

碼:

using (SqlConnection sqlConnection = new SqlConnection(Connectionstring))
{
    sqlConnection.Open();
    Member customer = sqlConnection.Query<Member>("SELECT * FROM member");
    return customer;
}

您需要在.cs文件中放置using語句,以使Dapper擴展方法可用。

using ...;
using Dapper;
using ...;

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM