Component V1.7 version adds support for MySQL (Test MySQL 5.1 version).
The following shows how to use the.
First add connectionstring
<add name= "mysqlconnectionstring" connectionstring= "Server=192.168.1.175;user id=root; PASSWORD=HUXJ; Port=3306;database=test "providername=" Hxj.Data.MySql "/>
public static Dbsession mysqltest = new Dbsession ("mysqlconnectionstring");
A new table mtable is created in the test database with only two fields: Mid int grows, mname varchar (50) and then uses the Entity build tool to generate entities. Test to add the data, the code is as follows:
Mtable m = new Mtable();
m.Mname = Hxj.Common.StringHelper.GetRandomString();
int returnValue = Db.MySqlTest.Insert<Mtable>(m);
The generated SQL is as follows:
Text:insert into ' mtable ' (' Mname ') VALUES (? swbeetoamhazjwa); select last_insert_id (); Parameters:?swbeetoamhazjwa[string] = wzfjpjidvkpp15hkryxo4w==
Re-test Bulk add:
using (DbBatch batch = Db.MySqlTest.BeginBatchConnection(5))
{
for (int i = 0; i < 10; i++)
{
Mtable m = new Mtable();
m.Mname = Hxj.Common.StringHelper.GetRandomString();
batch.Insert<Mtable>(m);
}
}