adriancs
Coder
Hi, guys, I have published a class library called "MySqlExpress" and I'm excited to share it here with you.
The class library stands on top of MySqlConnector and it aims to simplify the usage of MySQL in C# / .NET environment.
The primary purpose of this library is to simplify the implementation/usage of MySQL in C#. This is to encourage the rapid application development with MySQL in C#.
Project Site: https://github.com/adriancs2/MySqlExpress
Here is one of the example of what MySqlExpress can do.
Assuming that we have a MySQL table like this:
MySqlExpress Helper can help to generate the C# class object of "player":
To get a row object of "player", in C#, we can do like this:
To get multiple rows of "player" object, we can do it like this:
There are some more "simplified" methods available.
You guys are welcome to visit the github page of the project. I have included a demo project in the source code to show case the usage of MySqlExpress that you might be interested with.
Cheers, guys
Here's the screenshot of the Demo of using MySqlExpress included in the source code:
The class library stands on top of MySqlConnector and it aims to simplify the usage of MySQL in C# / .NET environment.
The primary purpose of this library is to simplify the implementation/usage of MySQL in C#. This is to encourage the rapid application development with MySQL in C#.
Project Site: https://github.com/adriancs2/MySqlExpress
Here is one of the example of what MySqlExpress can do.
Assuming that we have a MySQL table like this:
SQL:
CREATE TABLE `player` (
`id` int unsigned NOT NULL AUTO_INCREMENT,
`code` varchar(10),
`name` varchar(300),
`date_register` datetime,
`tel` varchar(100),
`email` varchar(100),
`status` int unsigned,
PRIMARY KEY (`id`));
C#:
public class obPlayer
{
public int id { get; set; }
public string code { get; set; }
public string name { get; set; }
public DateTime date_register { get; set; }
public string tel { get; set; }
public string email { get; set; }
public int status { get; set; }
}
C#:
int id = 1;
// declare the object
obPlayer p = null;
using (var conn = new MySqlConnection(config.ConnString))
{
using (MySqlCommand cmd = new MySqlCommand())
{
cmd.Connection = conn;
conn.Open();
MySqlExpress m = new MySqlExpress(cmd);
// parameterize the values
var dicParam = new Dictionary<string, object>();
dicParam["@vid"] = id;
p = m.GetObject<obPlayer>($"select * from player where id=@vid;",
dicParam);
conn.Close();
}
}
C#:
// declare the object list
List<obPlayer> lst = null;
using (var conn = new MySqlConnection(config.ConnString))
{
using (MySqlCommand cmd = new MySqlCommand())
{
cmd.Connection = conn;
conn.Open();
MySqlExpress m = new MySqlExpress(cmd);
// parameterize the values
var dicParam = new Dictionary<string, object>();
dicParam["@vname"] = "%adam%";
lst = m.GetObjectList<obPlayer>($"select * from player where name like @vname;",
dicParam);
conn.Close();
}
}
You guys are welcome to visit the github page of the project. I have included a demo project in the source code to show case the usage of MySqlExpress that you might be interested with.
Cheers, guys
Here's the screenshot of the Demo of using MySqlExpress included in the source code:
