Skip to content

Generated SQL error in MySQL #277

Description

@Kev12853

Hi, trying out Dapper.Simple. I am getting an error when using connection.Get(1).

MySQL table definition is
Id int NOT NULL AUTO_INCREMENT,
first_name varchar(45) DEFAULT NULL,
last_name varchar(45) DEFAULT NULL,
email varchar(45) DEFAULT NULL,
mobile_phone varchar(45) DEFAULT NULL,
PRIMARY KEY (Id),
UNIQUE KEY id_UNIQUE (Id)

c# class
[Table("tenants")]
public partial class Tenant
{
public string email { get; set; }
public string first_name { get; set; }
public int Id { get; set; }
public string last_name { get; set; }
public string mobile_phone { get; set; }
}

c# code
string connectionString = "datasource=localhost;port=3306;username=root;password=Th0rnyy760903c;database=portfolio_manager;";
MySqlConnection conn = new MySqlConnection(connectionString);
conn.Open();
var tenant = conn.Get(1);

and finally the error returned
You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '[email],[first_name],[Id],[last_name],[mobile_phone] from [tenants] where [Id] =' at line 1

Error code given is -2147467259

Where am I going wrong?

Many thanks
Kevin Thornicroft

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions