偷偷摘套内射激情视频,久久精品99国产国产精,中文字幕无线乱码人妻,中文在线中文a,性爽19p

對(duì)于使用ADO.NET通用接口創(chuàng)建對(duì)象

開發(fā) 后端
使用ADO.NET通用接口的另一個(gè)好處是它能被繼承用于建立強(qiáng)類型的DataSet。強(qiáng)類型DataSet的好處包括設(shè)計(jì)時(shí)的檢查和強(qiáng)類型DataSet 的Visual Studio .NET語句填充。

對(duì)于ADO.NET通用接口的相關(guān)使用還是比較常見,就使用ADO.NET DbProviderFactories并擴(kuò)充兼容mysql我深入的研究了一下,我們現(xiàn)在一起來看看吧。ADO.NET2.0 為各種ADO.NET類引入了一個(gè)提供程序工廠的模型以及通用基類。

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

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

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

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

2009-12-21 16:53:06

ADO.NET使用說明

2009-12-21 14:39:09

ADO.NET技巧

2009-12-21 17:35:24

ADO.NET對(duì)象

2010-01-04 10:14:04

ADO.NET對(duì)象模型

2009-12-23 14:07:09

ADO.NET實(shí)例對(duì)象

2009-11-04 09:18:12

ADO.NET _Re

2009-11-13 14:38:45

ADO.NET Dat

2009-12-25 10:25:59

2009-12-18 13:52:39

ADO.NET設(shè)計(jì)器

2009-12-23 09:32:26

ADO.NET數(shù)據(jù)對(duì)象

2009-11-04 09:02:34

ADO.NET _C

2009-12-18 17:06:37

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

2009-12-23 14:59:32

ADO.NET 2.0

2009-12-23 16:05:47

ADO.NET錯(cuò)誤

2009-11-04 12:45:33

ADO.NET Dat

2009-12-23 17:54:01

ADO.NET 2.0

2009-12-23 16:43:34

ADO.NET模型

2009-10-29 13:34:01

ADO.NET對(duì)象

2009-12-28 15:11:36

ADO.NET專家

2009-11-12 09:36:32

ADO.NET Sql
點(diǎn)贊
收藏

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