7
I’m testing Dapper and when I try to use a class I found the error:
Must declare the scalar variable
Follows the code:
public class Teste
{
public int id;
public string nome;
public int idade;
}
using (IDbConnection db = new SqlConnection(conexao))
{
Teste t = new Teste();
t.nome = "Iago";
t.idade = 20;
var newTeste = db.Execute("Insert Into Teste (nome, idade) Values(@nome, @idade)", t);
var teste = db.Query("Select * From Teste");
}
Table:
Create Table Teste (
id int identity(1,1),
nome varchar(50),
idade int
)
Maniero, thank you so much had not noticed the lack of get/set in the class. It worked great.
– Marcos Silva