小编Mat*_*oso的帖子

像 DataAdapter 这样的 Dapper 命令

拜托,我可以将此方法转换为使用 Dapper 吗?

  • “BuscarUltimasLeituras”是一个程序
  • “@Last”是过程的参数(int)

public DataTable GetLeituras ( int ultimas )
    {
        DataTable listaLeiturasRomaneio = new DataTable();
        try
        {
            _sqlConnection.Open();

            _sqlCommand = new SqlCommand();
            _sqlCommand.Connection = _sqlConnection;
            _sqlCommand.CommandText = "BuscarUltimasLeituras";
            _sqlCommand.CommandType = System.Data.CommandType.StoredProcedure;
            _sqlCommand.Parameters.Add("@Last", SqlDbType.Int).Value = ultimas;
            _sqlAdapter = new SqlDataAdapter(_sqlCommand);
            _sqlAdapter.Fill(listaLeiturasRomaneio);
        }
        catch ( SqlException )
        {
            listaLeiturasRomaneio = null;
        }
        finally
        {
            _sqlConnection.Close();
        }
        return listaLeiturasRomaneio;
    }
Run Code Online (Sandbox Code Playgroud)

c# stored-procedures sqldataadapter dapper

1
推荐指数
1
解决办法
1966
查看次数

标签 统计

c# ×1

dapper ×1

sqldataadapter ×1

stored-procedures ×1