In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-04-02 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >
Share
Shulou(Shulou.com)06/02 Report--
This article shows you how to understand the development and compatibility of ADO.NET DbProviderFactories. The content is concise and easy to understand. It will definitely brighten your eyes. I hope you can get something through the detailed introduction of this article.
The development of ADO.NET DbProviderFactories is still very fast. I have studied it deeply using ADO.NET DbProviderFactories and extending compatible mysql. I would like to share it with you here. Let's take a look at it now. ADO.NET2.0 .
Limitations of the ADO.NET generic interface: the interface is not easy to extend, ADO.NET1.1 cannot create instances of certain classes, and ADO.NET1.1 cannot determine which .NET data providers are available. Provides how the factory model overcomes the above limitations and extends the ADO,NET model through abstract accumulation.
Use the ADO.NET DbProviderFactories class to create objects. Due to the limitations of the provider factory model, many query structures are database-specific. When setting up CommandText for parameterized queries, provider-specific code may be required, and specifying parameter data types may require provider-specific code.
In order to make the developed code universal, not limited to a specific database, this development decided to use the DbProviderFactory+ standard SQL to develop a package suitable for mysql and sqlserver, but DbProviderFactories does not provide support for mysql's DbProviderFactory, so it is necessary to extend the ADO.NET DbProviderFactories class to be compatible with mysql, and both mysql and sqlserver's ParameterMarkerFormat in ADO.net 2.0 have bug, so the extension class has to solve this bug.
Public static class DbProviderFactoriesEx {public static DbProviderFactory GetFactory (string providerName)
{if (providerName = = null) throw new ArgumentNullException ("providerName"); DbProviderFactory dbFactory
Switch (providerName) {case "MySql.Data.MySqlClient": return new MySqlClientFactory (); default:
Return DbProviderFactories.GetFactory (providerName);}} public static string GetParameterMarkerFormat (DbConnection connect)
{if (connect = = null) throw new ArgumentNullException ("connect"); Type type = connect.GetType ()
If (type = = typeof (MySql.Data.MySqlClient.MySqlConnection)) return "? {0}"; / / mysql bug
If (type = = typeof (System.Data.SqlClient.SqlConnection)) return "@ {0}"; / / ms bug connect.Open ()
String result = connect.GetSchema ("DataSourceInformation"). Rows [0] ["ParameterMarkerFormat"] .ToString (); connect.Close (); return result;}}
The above is how to understand the development and compatibility of ADO.NET DbProviderFactories. Have you learned any knowledge or skills? If you want to learn more skills or enrich your knowledge reserve, you are welcome to follow the industry information channel.
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 203
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.