国产探花免费观看_亚洲丰满少妇自慰呻吟_97日韩有码在线_资源在线日韩欧美_一区二区精品毛片,辰东完美世界有声小说,欢乐颂第一季,yy玄幻小说排行榜完本

首頁 > 學院 > 開發設計 > 正文

ADO.NET2.0跟ADO.NET3.0的一些新特性簡要介紹

2019-11-18 17:01:38
字體:
來源:轉載
供稿:網友


覺得很多人在寫關于asp.net2.0的東東,很少有人寫關于ADO.NET2.0的新特性。查找了一下MSDN,給大家介紹幾點好了。(如果需要察看所有ADO.NET2.0的新特性,請查看

http://msdn2.microsoft.com/en-us/library/ex6y04yf.aspx

 

Server Enumeration

用來枚舉活動狀態的SQL Server實例,版本需要在SQL2000及更新版本。使用的是SqlDataSourceEnumerator類

 

可以參考以下示例代碼:


using System.Data.Sql;

class PRogram
{
  static void Main()
  {
    // Retrieve the enumerator instance and then the data.
    SqlDataSourceEnumerator instance =
      SqlDataSourceEnumerator.Instance;
    System.Data.DataTable table = instance.GetDataSources();

    // Display the contents of the table.
    DisplayData(table);

    Console.WriteLine("Press any key to continue.");
    Console.ReadKey();
  }

  private static void DisplayData(System.Data.DataTable table)
  {
    foreach (System.Data.DataRow row in table.Rows)
    {
      foreach (System.Data.DataColumn col in table.Columns)
      {
        Console.WriteLine("{0} = {1}", col.ColumnName, row[col]);
      }
      Console.WriteLine("============================");
    }
  }
}


DataSet Enhancements

新的DataTableReader類可以說是一個DataSet或者DataTable,的一個或者多個的read-only, forward-only的結果集。需要說明的是,DataTable返回的DataTableReader不包含被標記為deleted的行。

示例:


private static void TestCreateDataReader(DataTable dt)
{
    // Given a DataTable, retrieve a DataTableReader
    // allowing access to all the tables' data:
    using (DataTableReader reader = dt.CreateDataReader())
    {
        do
        {
            if (!reader.HasRows)
            {
                Console.WriteLine("Empty DataTableReader");
            }
            else
            {
                PrintColumns(reader);
            }
            Console.WriteLine("========================");
        } while (reader.NextResult());
    }
}

private static DataTable GetCustomers()
{
    // Create sample Customers table, in order
    // to demonstrate the behavior of the DataTableReader.
    DataTable table = new DataTable();

    // Create two columns, ID and Name.
    DataColumn idColumn = table.Columns.Add("ID", typeof(int));
    table.Columns.Add("Name", typeof(string));

    // Set the ID column as the primary key column.
    table.PrimaryKey = new DataColumn[] { idColumn };

    table.Rows.Add(new object[] { 1, "Mary" });
    table.Rows.Add(new object[] { 2, "Andy" });
    table.Rows.Add(new object[] { 3, "Peter" });
    table.Rows.Add(new object[] { 4, "Russ" });
    return table;
}

private static void PrintColumns(DataTableReader reader)
{
    // Loop through all the rows in the DataTableReader
    while (reader.Read())
    {
        for (int i = 0; i < reader.FieldCount; i++)
        {
            Console.Write(reader[i] + " ");
        }
        Console.WriteLine();
    }
}

 

 

Binary Serialization for the DataSet

關于這點linkcd已經寫過一篇性能測試的文章:.Net 2.0 下Data Container性能比較: Binary Serialize Dataset vs Custom Classes

 

DataTable as a Stand-Alone Object

很多以前DataSet的方法,現在可以用DataTable直接使用了

 

Create a DataTable from a DataView

現在可以從DataView返回一個DataTable了,兩者基本是一樣的,當然你也可以有選擇性的返回,比如說返回distinct rows

 

New DataTable Loading Capabilities

DataTables跟DataSets現在提供一個新的Load方法,可以直接把DataReader中的數據流載入到DataTable中,當然你也可以對如何Load做一些選擇。

 

 

以上是ADO.NET2.0的一些特性,你使用.NET2.0進行開發,就可以使用這些特性。

更激動人心的在于ADO.NET3.0的一些特性.

有文章介紹了一些ADO.NET3.0 AUGUT CTP的一些特性:

 

The ADO.NET Entity Framework

The Entity Data Model (EDM),實體數據模型,開發者可以以更高的抽象層次來設計數據模型
一個很牛的client-views/mapping引擎,用來映射(map to and form)存儲結構(store schemas )
完全支持使用Entity SQL跟LINQ( 這東西現在出現頻率還挺高的哦,也挺好玩的一個東東)查詢EDM schemas
.....
LINQ(AUGUST CTP):

LINQ to Entities: 使用LINQ查詢EDM schemas
LINQ to DataSet: 對一個或者多個DataTable進行LINQ查詢
都是很期待的技術,Enjoy it!:)


http://www.survivalescaperooms.com/wdxinren/archive/2006/09/04/494260.html


發表評論 共有條評論
用戶名: 密碼:
驗證碼: 匿名發表
主站蜘蛛池模板: 连云港市| 禹州市| 乌苏市| 吉隆县| 罗平县| 静海县| 淄博市| 鄂托克前旗| 勃利县| 南涧| 偏关县| 中江县| 奎屯市| 疏附县| 大厂| 遵义县| 彭山县| 曲松县| 衡山县| 新建县| 视频| 楚雄市| 太仆寺旗| 英吉沙县| 兴义市| 香格里拉县| 威信县| 兰坪| 额尔古纳市| 谷城县| 周至县| 信阳市| 蒲江县| 晋宁县| 永城市| 望都县| 阜阳市| 化州市| 沙田区| 浠水县| 达州市|