MarcoMySql DataProvider
MarcoMySql è la rifattorizzazione del Data Provider per MySql (Connector 1.0.7) al fine di implementare le classe basi contenute nel namespace System.Data.Common.
La rifattorizzazione comprende l'aggiornamento di alcune classi e l'implementazione della nuova classe factory MySqlProviderFactory (MySql.Data.MySqlClient).
La classe MySqlProviderFactory ci consente di utilizzare MySql insieme al controllo SqlDataSource.
Una volta copiata la dll nella cartella \bin\, è sufficente aggiungere nel Web.Config le seguenti righe:
<system.data><br /> <DbProviderFactories><br /> <add name="MarcoMySql Data Provider" invariant="MySql.Data.MySqlClient" description="Marco MySql Provider" type="MySql.Data.MySqlClient.MySqlProviderFactory, MarcoMySql.Data, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null" /><br /> </DbProviderFactories><br /></system.data>
Potremo infine aggiungere ad esempio un SqlDataSource collegato ad una GridView, così configurato sulla nostra pagina, che funzionerà al 100% con MySQL, prestando particolare attenzione a impostare il nome del Provider su "MySql.Data.MySqlClient":
<asp:SqlDataSource ID="SqlDataSource1" runat="server" ConnectionString="Server=localhost;Uid=root;Pwd=X;Database=aspitalia;"<br />ProviderName="MySql.Data.MySqlClient" SelectCommand="select ID, Name, Address from Customer"<br />InsertCommand="INSERT INTO customer VALUES(null, ?name, ?address)" <br />DeleteCommand="DELETE FROM customer WHERE ID = ?ID "<br />UpdateCommand="UPDATE customer SET name=?name, address=?address WHERE ID = ?ID;"><br /> <InsertParameters><br /> <asp:ControlParameter ControlID="TextBoxName" ConvertEmptyStringToNull="true" Name="name" /><br /> <asp:ControlParameter ControlID="TextBoxAddress" ConvertEmptyStringToNull="true" Name="address" /><br /> </InsertParameters><br /></asp:SqlDataSource>
Si puossono scaricare direttamente sorgenti ed assembly.
English version
MarcoMySql is a MySql (Connector 1.0.7) Data Provider compliant with the new classes required by System.Data.Common and the new Factory architecture of ADO.NET.
This release includes new updated classes and a brand new MySqlProviderFactory class(MySql.Data.MySqlClient).
MySqlProviderFactory allows you to use MySql with a SqlDataSource control.
You have to deploy the file in the \bin\ directory and add this rows to your Web.Config file:
<system.data><br /> <DbProviderFactories><br /> <add name="MarcoMySql Data Provider" invariant="MySql.Data.MySqlClient" description="Marco MySql Provider" type="MySql.Data.MySqlClient.MySqlProviderFactory, MarcoMySql.Data, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null" /><br /> </DbProviderFactories><br /></system.data>
Now you can add a SqlDataSource control bound to a GridView one, that will work the same way as using SQL Server, setting the Provider property on "MySql.Data.MySqlClient":
<asp:SqlDataSource ID="SqlDataSource1" runat="server" ConnectionString="Server=localhost;Uid=root;Pwd=X;Database=aspitalia;"<br />ProviderName="MySql.Data.MySqlClient" SelectCommand="select ID, Name, Address from Customer"<br />InsertCommand="INSERT INTO customer VALUES(null, ?name, ?address)" <br />DeleteCommand="DELETE FROM customer WHERE ID = ?ID "<br />UpdateCommand="UPDATE customer SET name=?name, address=?address WHERE ID = ?ID;"><br /> <InsertParameters><br /> <asp:ControlParameter ControlID="TextBoxName" ConvertEmptyStringToNull="true" Name="name" /><br /> <asp:ControlParameter ControlID="TextBoxAddress" ConvertEmptyStringToNull="true" Name="address" /><br /> </InsertParameters><br /></asp:SqlDataSource>
You can freely download the source and the assembly here.
Commenti
Per inserire un commento, devi avere un account.
Fai il login e torna a questa pagina, oppure registrati alla nostra community.
Approfondimenti
Load test di ASP.NET Core con k6
Short-circuiting della Pipeline in ASP.NET Core
Eseguire una query su SQL Azure tramite un workflow di GitHub
Implementare il throttling in ASP.NET Core
Personalizzare l'errore del rate limiting middleware in ASP.NET Core
Effettuare il deploy di immagini solo da container registry approvati in Kubernetes