自拍偷在线精品自拍偷,亚洲欧美中文日韩v在线观看不卡

ADO.NET DbProviderFactories發(fā)展與兼容說明

開發(fā) 后端
ADO.NET DbProviderFactories 集成開發(fā)環(huán)境包括許多新的和改進的用于提高工作效率的功能。IDE 還進行了重新設(shè)計,從而向開發(fā)人員提供對.NET Framework 組件的直接訪問。

ADO.NET DbProviderFactories發(fā)展還是很快的,就使用ADO.NET DbProviderFactories并擴充兼容mysql我深入的研究了一下,在這里給大家分享一下,我們現(xiàn)在一起來看看吧。ADO.NET2.0 。

ADO.NET通用接口的限制:接口不易擴展,ADO.NET1.1無法創(chuàng)建某些類的實例,ADO.NET1.1無法判斷可用的.NET數(shù)據(jù)提供程序。提供工廠模型如何解決上述限制,通過抽象積累來擴展ADO,NET模型,#t#

使用ADO.NET DbProviderFactories類來創(chuàng)建對象。提供程序工廠模型的限制,許多查詢結(jié)構(gòu)都是數(shù)據(jù)庫特有的。為參數(shù)化查詢設(shè)置CommandText時,可能需要提供程序特有的代碼,指定參數(shù)數(shù)據(jù)類型可能需要提供程序特有的代碼。

為了使開發(fā)的代碼通用,不局限于特定的數(shù)據(jù)庫,本次開發(fā)中決定使用DbProviderFactory+標(biāo)準(zhǔn)SQL,以開發(fā)一個適用于mysql和 sqlserver的封裝,但DbProviderFactories 并沒有提供對mysql的DbProviderFactory的支持,所以需要擴充ADO.NET DbProviderFactories類兼容mysql,而且在ADO.net 2.0中mysql和sqlserver的ParameterMarkerFormat都有bug,所以擴展類要解決這個bug。

  1. public static class DbProviderFactoriesEx  {  public static DbProviderFactory GetFactory(string providerName) 
  2. {  if (providerName == null)  throw new ArgumentNullException("providerName");  DbProviderFactory dbFactory; 
  3. switch (providerName)  {  case "MySql.Data.MySqlClient":  return new MySqlClientFactory();  default:  
  4. return DbProviderFactories.GetFactory(providerName);  }  }  public static string GetParameterMarkerFormat(DbConnection connect) 
  5. {  if (connect == null)  throw new ArgumentNullException("connect");  Type type = connect.GetType(); 
  6. if (type == typeof(MySql.Data.MySqlClient.MySqlConnection))  return "?{0}";//mysql bug  
    if (
    type == typeof(System.Data.SqlClient.SqlConnection))  return "@{0}";//ms bug  connect.Open();  
  7. string result = connect.GetSchema("DataSourceInformation").Rows[0]["ParameterMarkerFormat"].ToString();  connect.Close();  return result;  }  }  
責(zé)任編輯:chenqingxiang 來源: it168
相關(guān)推薦

2009-11-04 10:07:52

ADO.NET DbP

2009-12-21 17:29:43

ADO.NET模型

2009-12-24 09:34:47

調(diào)用ADO.NET

2009-12-22 17:43:26

ADO.Net技術(shù)

2009-12-30 16:05:20

ADO.NET實例

2009-12-22 11:17:58

ADO.NET產(chǎn)品

2009-12-21 10:37:05

Ado.Net 實例

2010-01-04 09:03:57

ADO.NET連接對象

2009-12-22 09:15:02

ADO.NET功能

2009-12-30 15:11:35

ADO.NET數(shù)據(jù)

2009-12-21 14:55:49

ADO.NET屬性

2009-12-21 11:29:13

Ado.Net代碼

2010-01-04 13:16:31

ADO.NET命令

2009-12-18 17:01:21

ADO.NET數(shù)據(jù)

2009-12-24 14:49:38

ADO.NET運行錯誤

2010-01-04 10:19:45

ADO.NET Dat

2009-12-21 15:52:30

ADO.NET對象

2009-12-22 15:51:18

ADO.NET代碼

2009-12-22 14:52:54

ADO.NET腳本

2009-12-25 09:25:54

ADO.NET實例
點贊
收藏

51CTO技術(shù)棧公眾號