{"id":16408956,"url":"https://github.com/adriancs2/mysqlexpress","last_synced_at":"2025-10-26T17:32:25.534Z","repository":{"id":64393780,"uuid":"574524535","full_name":"adriancs2/MySqlExpress","owner":"adriancs2","description":"MySqlExpress get rows from MySQL table and convert it into Class Objects in C#. For saving data, Class Objects and be passed for executing INSERT or UPDATE. It can also performs INSERT/UPDATE by using Dictionary.","archived":false,"fork":false,"pushed_at":"2023-04-14T09:28:53.000Z","size":17193,"stargazers_count":6,"open_issues_count":0,"forks_count":4,"subscribers_count":3,"default_branch":"master","last_synced_at":"2024-10-30T05:43:23.352Z","etag":null,"topics":["asp-net","csharp","mysql"],"latest_commit_sha":null,"homepage":"","language":"C#","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"unlicense","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/adriancs2.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2022-12-05T13:57:38.000Z","updated_at":"2023-10-21T01:13:26.000Z","dependencies_parsed_at":"2024-10-11T06:18:33.086Z","dependency_job_id":"d660649d-c4fc-4d2a-a1ae-95720548d669","html_url":"https://github.com/adriancs2/MySqlExpress","commit_stats":{"total_commits":90,"total_committers":1,"mean_commits":90.0,"dds":0.0,"last_synced_commit":"0c0a6921020195d28802b54c9639c87f14e0e296"},"previous_names":[],"tags_count":14,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/adriancs2%2FMySqlExpress","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/adriancs2%2FMySqlExpress/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/adriancs2%2FMySqlExpress/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/adriancs2%2FMySqlExpress/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/adriancs2","download_url":"https://codeload.github.com/adriancs2/MySqlExpress/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":238375326,"owners_count":19461584,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["asp-net","csharp","mysql"],"created_at":"2024-10-11T06:18:30.981Z","updated_at":"2025-10-26T17:32:19.028Z","avatar_url":"https://github.com/adriancs2.png","language":"C#","funding_links":[],"categories":[],"sub_categories":[],"readme":"# MySqlExpress\nMySqlExpress get rows from MySQL table and convert it into Class Objects in C#. For saving data, Class Objects and be passed for executing INSERT or UPDATE. It can also performs INSERT/UPDATE by using Dictionary. It simplifies the usage of MySQL in C#.\n\nThis class library aims to encourage rapid application development with MySQL.\n\nGithub: [https://github.com/adriancs2/MySqlExpress](https://github.com/adriancs2/MySqlExpress)\n\n[Nuget for MySqlConnector (MIT) - https://www.nuget.org/packages/MySqlExpress](https://www.nuget.org/packages/MySqlExpress)\n\nPM\u003e NuGet\\Install-Package MySqlExpress\n\n[Nuget for MySql.Data (Oracle) - https://www.nuget.org/packages/MySqlExpress.MySql.Data](https://www.nuget.org/packages/MySqlExpress.MySql.Data)\n\nPM\u003e NuGet\\Install-Package MySqlExpress.MySql.Data\n\nDownload **MySqlExpress Helper**: [https://github.com/adriancs2/MySqlExpress/releases](https://github.com/adriancs2/MySqlExpress/releases)\n\n_The Demo of MySqlExpress (Available in source code):_\n\n![MySqlExpress Demo](https://raw.githubusercontent.com/adriancs2/MySqlExpress/master/wiki/screenshot05.png)\n\n## Introduction\n\nMySqlExpress consists of 2 parts.\n\nThe **first part** is the C# class library of MySqlExpress. It introduces some \"shortcuts\" as to simplify the execution of tasks related to MySQL.\n\nTo begin with, download the source code and add the class file \"MySqlExpress.cs\" into your project,\n\nor add the referrence of the project of MySqlExpress into your project,\n\nor install the Nuget package of MySqlExpress into your project.\n\nThe **second part** is a software called **\"MySqlExpress Helper.exe\"**. The main function of this software is to generate C# class objects, which will be explained in details below. I'll refer this small program as the **\"Helper App\"** for the rest of this article.\n\nDownload **MySqlExpress Helper**: [https://github.com/adriancs2/MySqlExpress/releases](https://github.com/adriancs2/MySqlExpress/releases)\n\nMySqlExpress is built on top of MySqlConnector (MIT) library. If you wish to use another connector or provider, you can download the source code and compile it with your favorite connector.\n\n## Before Start\n\nAs usual, to begin coding with MySQL, first add the following using statement to allow the usage of MySqlconnector (MIT) library.\n```csharp\nusing MySqlConnector;\n```\nIn this article, let's assume that we store the MySQL connection string as a static field. For example:\n```csharp\npublic class config\n{\n    public static string ConnString = \n        \"server=localhost;user=root;pwd=1234;database=test;\";\n}\n```\nHence, we can obtain the connection string anywhere in the project as below:\n\n```csharp\nconfig.ConnString\n```\n\nHere is the standard MySQL connection code block:\n```csharp\nusing (MySqlConnection conn = new MySqlConnection(config.ConnString))\n{\n    using (MySqlCommand cmd = new MySqlCommand())\n    {\n        cmd.Connection = conn;\n        conn.Open();\n\n        // execute queries\n\n        conn.Close();\n    }\n}\n```\nDeclare a new MySqlExpress object to start using:\n```csharp\nusing (MySqlConnection conn = new MySqlConnection(config.ConnString))\n{\n    using (MySqlCommand cmd = new MySqlCommand())\n    {\n        cmd.Connection = conn;\n        conn.Open();\n\n        MySqlExpress m = new MySqlExpress(cmd);\n\n        // perform queries\n\n        conn.Close();\n    }\n}\n```\nThe standard MySQL connection code block shown above can be saved into Visual Studio toolbox bar. So, next time, whenever you need this code block, you can drag and drop from the toolbox bar.\n\n![](https://raw.githubusercontent.com/adriancs2/MySqlExpress/master/wiki/02.png)\n\nNow the code block is saved at the toolbox.\n\n![](https://raw.githubusercontent.com/adriancs2/MySqlExpress/master/wiki/03.png)\n\nNext time, whenever you need the code block, just drag it from the toolbox into the text editor.\n\n![](https://raw.githubusercontent.com/adriancs2/MySqlExpress/master/wiki/05.png)\n\n## Let's Start - Using MySqlExpress\n\n1. Start Transaction, Commit, Rollback\n2. Getting Rows of Objects from MySQL Table\n3. Getting a Customized Object Structure\n4. Getting a single value (ExecuteScalar\u003cT\u003e)\n5. Save (v.17) - Saving Objects\n6. Insert Row (Save Data)\n7. Update Row (Update Data)\n8. Insert Update\n9. Generate Like String\n10. Execute a SQL statement\n  \n###  1. Start Transaction, Commit and Rollback\n```csharp\nusing (MySqlConnection conn = new MySqlConnection(config.ConnString))\n{\n    using (MySqlCommand cmd = new MySqlCommand())\n    {\n        cmd.Connection = conn;\n        conn.Open();\n\n        MySqlExpress m = new MySqlExpress(cmd);\n\n        try\n        {\n            m.StartTransaction();\n\n            // perform lots of queries\n            // action success\n\n            m.Commit();\n        }\n        catch\n        {\n            // Error occur\n\n            m.Rollback();\n        }\n\n        conn.Close();\n    }\n}\n```\nThere are a few benefits of using TRANSACTION in MySQL.\n\nOn a 7200 rpm HDD hard drive, the maximum I/O writes (numbers of SQL queries) that MySQL can executes is around 100 to 120 times.\n\nRead more about MySQL Disk I/O Capacity at: [https://dev.mysql.com/doc/refman/5.7/en/innodb-configuring-io-capacity.html](https://dev.mysql.com/doc/refman/5.7/en/innodb-configuring-io-capacity.html)\n\nIf you perform 1000 queries, they will be executed one by one, which will take around 4~7 seconds on HDD hard drive to complete.\n\nBy using TRANSACTION + COMMIT, all 1000 queries will all be executed at once. This saves a lots of disk operation time.\n\nSometimes, there are chains of operations which involves multiple tables and rows. Without transaction, if there is any bad thing or error occurs in the middle of the process, the whole operation will be terminated half way, resulting partial or incomplete data saving. Which would be a problematic to fix the data. Hence, TRANSACTION can prevent such thing happens. With transaction, the whole chain of operation will be cancelled.\n\nROLLBACK, means cancel. Discard all queries that sent during the TRANSACTION period.\n\nRead more about transaction at [here](https://www.mysqltutorial.org/mysql-transaction.aspx)\n\n### 2. Getting Rows of Objects from MySQL Table\n\nAssume that, we have a MySQL table like this:\n\n```sql\nCREATE TABLE `player` (\n`id` int unsigned NOT NULL AUTO_INCREMENT,\n`code` varchar(10),\n`name` varchar(300),\n`date_register` datetime,\n`tel` varchar(100),\n`email` varchar(100),\n`status` int unsigned,\nPRIMARY KEY (`id`));\n```\nFirst, creates a new class.\n  \n```csharp\npublic class obPlayer\n{\n   \n}\n```\n\nThe name of class. If the MySQL table's name is \"player\", you can name the class as \"obPlayer\".\n\n\"ob\" means \"object\".\n\n\"obPlayer\", an object of \"Player\".\n\nBut, anyway, you can name the class anything according to your personal flavor, of course.\n\nNext, create the class object's fields or properties:\n\nThere are 3 modes of creating the fields or properties:\n\n1. Private Fields + Public Properties\n2. Public Properties\n3. Public Fields\n\nRun the **Helper** app.\n\n**First Mode: Private Fields + Public Properties**\n   \n![](https://raw.githubusercontent.com/adriancs2/MySqlExpress/master/wiki/f03.png)\n\nPaste the text into the class:\n    \n```csharp\npublic class obPlayer\n{\n    int id = 0;\n    string code = \"\";\n    string name = \"\";\n    DateTime date_register = DateTime.MinValue;\n    string tel = \"\";\n    string email = \"\";\n    int status = 0;\n\n    public int Id { get { return id; } set { id = value; } }\n    public string Code { get { return code; } set { code = value; } }\n    public string Name { get { return name; } set { name = value; } }\n    public DateTime DateRegister { get { return date_register; } set { date_register = value; } }\n    public string Tel { get { return tel; } set { tel = value; } }\n    public string Email { get { return email; } set { email = value; } }\n    public int Status { get { return status; } set { status = value; } }\n}\n```\n\nThe purpose using this combination (private fields + public properties):\n\nPrivate fields are used to match the columns' name of MySQL table and map the data.\n\nPublic properties are used to convert the naming of the fields into C# Coding Naming Convertions, which is PascalCase:\n\nRead more about [C# Coding Naming Conventions](https://github.com/ktaranov/naming-convention/blob/master/C%23%20Coding%20Standards%20and%20Naming%20Conventions.md)\n\nThe MySQL column's naming conventions uses lower case and underscore to separate words.\n\nRead more about [MySQL Naming Conventions](https://medium.com/@centizennationwide/mysql-naming-conventions-e3a6f6219efe)\n\nThe symbol of \"_\" (underscore) is considered less typing friendly than using just latin characters.\n\nTherefore, converting the field name to PacalCase will align with the C# naming conventions and also increase the convenient and speed of coding.\n    \n**Second Mode: Public Properties**\n\n![](https://raw.githubusercontent.com/adriancs2/MySqlExpress/master/wiki/g01.png)\n\nThen, paste all the copied text into the class:\n```csharp\npublic class obPlayer\n{\n    public int id { get; set; }\n    public string code { get; set; }\n    public string name { get; set; }\n    public DateTime date_register { get; set; }\n    public string tel { get; set; }\n    public string email { get; set; }\n    public int status { get; set; }\n}\n```\n\n**Third Mode: Public Fields**\n\n![](https://raw.githubusercontent.com/adriancs2/MySqlExpress/master/wiki/f02.png)\n\n```csharp\npublic class obPlayer\n{\n    public int id = 0;\n    public string code = \"\";\n    public string name = \"\";\n    public DateTime date_register = DateTime.MinValue;\n    public string tel = \"\";\n    public string email = \"\";\n    public int status = 0;\n}\n```\n\n**Getting a single row of \"Player\" object**\n\nHere's the code of getting a single row of \"Player\" object.\n```csharp\nint id = 1;\n\n// declare the object\nobPlayer p = null;\n\nusing (MySqlConnection conn = new MySqlConnection(config.ConnString))\n{\n    using (MySqlCommand cmd = new MySqlCommand())\n    {\n        cmd.Connection = conn;\n        conn.Open();\n\n        MySqlExpress m = new MySqlExpress(cmd);\n\n        // parameterize the values\n        Dictionary\u003cstring, object\u003e dicParam = new Dictionary\u003cstring, object\u003e();\n        dicParam[\"@vid\"] = id;\n\n        p = m.GetObject\u003cobPlayer\u003e($\"select * from player where id=@vid;\", dicParam);\n\n        conn.Close();\n    }\n}\n  ```\nGetting a list of objects (get multiple rows from a MySQL table):\n```csharp\n// declare the object list\nList\u003cobPlayer\u003e lst = null;\n\nusing (MySqlConnection conn = new MySqlConnection(config.ConnString))\n{\n    using (MySqlCommand cmd = new MySqlCommand())\n    {\n        cmd.Connection = conn;\n        conn.Open();\n\n        MySqlExpress m = new MySqlExpress(cmd);\n\n        // parameterize the values\n        Dictionary\u003cstring, object\u003e dicParam = new Dictionary\u003cstring, object\u003e();\n        dicParam[\"@vname\"] = \"%adam%\";\n\n        lst = m.GetObjectList\u003cobPlayer\u003e($\"select * from player where name like @vname;\", dicParam);\n\n        conn.Close();\n    }\n}\n```\n\n### 3. Getting a Customized Object Structure\nOne of the typical example is multiple SQL JOIN statement. For example:\n```sql\nselect a.*, b.`year`, c.name 'teamname', c.code 'teamcode', c.id 'teamid'\nfrom player a\ninner join player_team b on a.id=b.player_id\ninner join team c on b.team_id=c.id;\n```\n  \nThe output table structure is customized.\n\nTo create a non-standardized table's object structure, open the Helper program. Key in the customized SQL JOIN statement.\n\n![](https://raw.githubusercontent.com/adriancs2/MySqlExpress/master/wiki/g03.png)\n\nCreate the custom class object:\n\n```csharp\npublic class obPlayerTeam\n{\n   \n}\n```\nThen, paste the copied text into the new custom object:\n\n```csharp\npublic class obPlayerTeam\n{\n    int id = 0;\n    string code = \"\";\n    string name = \"\";\n    DateTime date_register = DateTime.MinValue;\n    string tel = \"\";\n    string email = \"\";\n    int status = 0;\n    int year = 0;\n    string teamname = \"\";\n    string teamcode = \"\";\n    int teamid = 0;\n\n    public int Id { get { return id; } set { id = value; } }\n    public string Code { get { return code; } set { code = value; } }\n    public string Name { get { return name; } set { name = value; } }\n    public DateTime DateRegister { get { return date_register; } set { date_register = value; } }\n    public string Tel { get { return tel; } set { tel = value; } }\n    public string Email { get { return email; } set { email = value; } }\n    public int Status { get { return status; } set { status = value; } }\n    public int Year { get { return year; } set { year = value; } }\n    public string Teamname { get { return teamname; } set { teamname = value; } }\n    public string Teamcode { get { return teamcode; } set { teamcode = value; } }\n    public int Teamid { get { return teamid; } set { teamid = value; } }\n}\n```\n\n  Getting the customized table object:\n```csharp\n// declare the object\nList\u003cobPlayerTeam\u003e lst = null;\n\n// parameterized the value\nDictionary\u003cstring, object\u003e dicParam = new Dictionary\u003cstring, object\u003e();\ndicParam[\"@vname\"] = \"%adam%\";\n\nusing (MySqlConnection conn = new MySqlConnection(config.ConnString))\n{\n    using (MySqlCommand cmd = new MySqlCommand())\n    {\n        cmd.Connection = conn;\n        conn.Open();\n\n        MySqlExpress m = new MySqlExpress(cmd);\n\n        lst = m.GetObjectList\u003cobPlayerTeam\u003e(@\"\n            select a.*, b.`year`, c.name 'teamname', c.code 'teamcode', c.id 'teamid'\n            from player a inner join player_team b on a.id=b.player_id\n            inner join team c on b.team_id=c.id\n            where a.name like @vname;\", dicParam);\n\n        conn.Close();\n    }\n}\n```\n  \n### 4. Getting a single value (ExecuteScalar\u003cT\u003e)\n```csharp\n// int\nint count = m.ExecuteScalar\u003cint\u003e(\"select count(*) from player;\");\n\n// datetime\nDateTime d = m.ExecuteScalar\u003cDateTime\u003e(\"select date_register from player where id=2;\");\n\n// string\nstring name = m.ExecuteScalar\u003cstring\u003e(\"select name from player where id=1;\");\n```\n\nGetting single value with parameters\n  \n```csharp\n// parameters\nDictionary\u003cstring, object\u003e dicParam1 = new Dictionary\u003cstring, object\u003e();\ndicParam1[\"@vname\"] = \"%adam%\";\n\nDictionary\u003cstring, object\u003e dicParam2 = new Dictionary\u003cstring, object\u003e();\ndicParam2[\"@vid\"] = 1;\n\n// int\nint count = m.ExecuteScalar\u003cint\u003e(\"select count(*) from player where name like @vname;\", dicParam1);\n\n// datetime\nDateTime d = m.ExecuteScalar\u003cDateTime\u003e(\"select date_register from player where id=@vid;\", dicParam2);\n\n// string\nstring name = m.ExecuteScalar\u003cstring\u003e(\"select name from player where id=@vid;\", dicParam2);\n\n```\n  \n### 5. Save (v1.7) - Saving Objects\n\nA combination of \"INSERT\" and \"UPDATE\".\nThis method will first attempt to perform an INSERT. If the primary key of the data has already existed in MySQL table, then it will perform an UPDATE.\n\n```csharp\n// Syntax\nm.Save(tablename, class);\nm.SaveList(tablename, List\u003cclass\u003e);\n\n// Example:\n\n// Saving single object\nm.Save(\"player\", player);\n\n// Saving list of objects\nm.SaveList(\"player\", lstPlayer);\n```\n  \n### 6. Insert Row (Save Data)\n\nPerforms INSERT by using dictionary.\n\n\u003e **Note:**\n\u003e **The dictionary values will be inserted as parameterized values**\n    \n![](https://raw.githubusercontent.com/adriancs2/MySqlExpress/master/wiki/g04.png)\n  \nThe field \"id\" is a primary key, auto-increment field. Therefore, we don't need to insert data for this field.\n\nDelete the following line from the block:\n    \n```csharp\ndic[\"id\"] =\n```\n\nFill in data into the dictionary:\n```csharp\nDictionary\u003cstring, object\u003e dic = new Dictionary\u003cstring, object\u003e();\n\ndic[\"code\"] = \"AA001\";\ndic[\"name\"] = \"John Smith\";\ndic[\"date_register\"] = DateTime.Now;\ndic[\"tel\"] = \"1298343223\";\ndic[\"email\"] = \"john_smith@mail.com\";\ndic[\"status\"] = 1;\n\nm.Insert(\"player\", dic);\n```\n  \nRun the following code to obtain new inserted ID:\n    \n```csharp\nm.LastInsertId\n```\n    \nObtain the LAST INSERT ID:\n  \n```csharp\nDictionary\u003cstring, object\u003e dic = new Dictionary\u003cstring, object\u003e();\n\ndic[\"code\"] = \"AA001\";\ndic[\"name\"] = \"John Smith\";\ndic[\"date_register\"] = DateTime.Now;\ndic[\"tel\"] = \"1298343223\";\ndic[\"email\"] = \"john_smith@mail.com\";\ndic[\"status\"] = 1;\n\nm.Insert(\"player\", dic);\n\nint newid = m.LastInsertId;\n```\n\n### 7 Update Row (Update Data)\n\nPerforms UPDATE by using dictionary.\n  \n\u003e **Note:**\n\u003e **The dictionary values will be inserted as parameterized values**\n\nFor updating table that has one primary key. The parameters:\n```csharp\nm.Update(tablename, dictionary, primary key column name, id);\n```\nGenerate the dictionary entries from the Helper App.\n    \nRemove the \"id\" dictionary entry:\n    \n```csharp\ndic[\"id\"] =\n```\n    \nPaste it at the code block, fill the value and execute the Update command:\n  \n```csharp\nDictionary\u003cstring, object\u003e dic = new Dictionary\u003cstring, object\u003e();\n\ndic[\"code\"] = \"AA001\";\ndic[\"name\"] = \"John Smith\";\ndic[\"date_register\"] = DateTime.Now;\ndic[\"tel\"] = \"1298343223\";\ndic[\"email\"] = \"john_smith@mail.com\";\ndic[\"status\"] = 1;\n\nm.Update(\"player\", dic, \"id\", 1);\n```\n  \nFor updating table that has multiple primary keys or multiple reference column. The parameters:\n```csharp\nm.Update(tablename, dictionary data, dictionary reference data);\n```\nExample:\n```csharp\n// data\nDictionary\u003cstring, object\u003e dic = new Dictionary\u003cstring, object\u003e();\ndic[\"code\"] = \"AA001\";\ndic[\"name\"] = \"John Smith\";\ndic[\"date_register\"] = DateTime.Now;\ndic[\"tel\"] = \"1298343223\";\ndic[\"email\"] = \"john_smith@mail.com\";\ndic[\"status\"] = 1;\n\n// update condition / referrence column data\nDictionary\u003cstring, object\u003e dicCond = new Dictionary\u003cstring, object\u003e();\ndicCond[\"year\"] = 2022;\ndicCond[\"team_id\"] = 1;\n\nm.Update(\"player_team\", dic, dicCond);\n```\n  \n### 8. Insert Update\n\nPerforms INSERT \u0026 UPDATE by using dictionary.\n  \n\u003e **Note:**\n\u003e **The dictionary values will be inserted as parameterized values**\n\nThis is especially useful when the table has multiple primary keys and no auto-increment field.\n\nInsert \u003e if the primary keys are not existed\n\nUpdate it \u003e if the primary keys existed.\n\nFirst, generate the dictionary entries:\n\n![](https://raw.githubusercontent.com/adriancs2/MySqlExpress/master/wiki/g05.png)\n\nNext, generate the update column list:\n\n![](https://raw.githubusercontent.com/adriancs2/MySqlExpress/master/wiki/g06.png)\n  \n  Paste it at the code block and runs the Insert Update method:\n```csharp\nList\u003cstring\u003e lstUpdateCol = new List\u003cstring\u003e();\n\nlstUpdateCol.Add(\"team_id\");\nlstUpdateCol.Add(\"score\");\nlstUpdateCol.Add(\"level\");\nlstUpdateCol.Add(\"status\");\n\nusing (MySqlConnection conn = new MySqlConnection(config.ConnString))\n{\n    using (MySqlCommand cmd = new MySqlCommand())\n    {\n        cmd.Connection = conn;\n        conn.Open();\n\n        MySqlExpress m = new MySqlExpress(cmd);\n\n        // data\n        Dictionary\u003cstring, object\u003e dic = new Dictionary\u003cstring, object\u003e();\n\n        dic[\"year\"] = 2022;\n        dic[\"player_id\"] = 1;\n        dic[\"team_id\"] = 1;\n        dic[\"score\"] = 10m;\n        dic[\"level\"] = 1;\n        dic[\"status\"] = 1;\n\n        m.InsertUpdate(\"player_team\", dic, lstUpdateCol);\n\n        conn.Close();\n    }\n}\n```\n  \n### 9. Generate Like String\n\n```csharp\nstring name = \"James O'Brien\";\n\n// parameters\nDictionary\u003cstring, object\u003e dicParam = new Dictionary\u003cstring, object\u003e();\ndicParam[\"@vname\"] = m.GetLikeString(name);\n\nList\u003cobPlayer\u003e lst = m.GetObjectList\u003cobPlayer\u003e(\"select * from player where name like @vname;\", dicParam);\n```\n  \n### 10. Execute a Single SQL statement\n \n```csharp\nDictionary\u003cstring, object\u003e dicParam = new Dictionary\u003cstring, object\u003e();\ndicParam[\"@vName\"] = \"James O'Brien\";\ndicParam[\"@vCode\"] = \"AA001\";\nm.Execute(\"delete from player where name=@vName or code=@vCode;\", dicParam);\n```\n  \nHappy coding.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fadriancs2%2Fmysqlexpress","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fadriancs2%2Fmysqlexpress","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fadriancs2%2Fmysqlexpress/lists"}