WEB开发网
开发学院数据库MSSQL Server ORM: 开发自己的Data Access Application Block -... 阅读

ORM: 开发自己的Data Access Application Block - Part II

 2008-12-06 10:15:42 来源:WEB开发网   
核心提示: Part II: Fill Dataset很简单,基本上ADO.NET 的基本操作,ORM: 开发自己的Data Access Application Block - Part II(2),没什么可值得说的,using System;using System.Collections.Gen

Part II: Fill Dataset

很简单,基本上ADO.NET 的基本操作,没什么可值得说的。

using System;
using System.Collections.Generic;
using System.Text;
using System.Data;
using System.Data.Common;
  
using Artech.ApplicationBlock.DataMapping;
  
namespace Artech.ApplicationBlock.DataAccess
{
  /**//// <summary>
  /// Database defines a series of database-based operations.
  /// </summary>
  public abstract partial class Database : IDisposable,
  {
   
    public void FillDataSet(DataSet dataInfo, string commandText, IDictionary<string, object> parameters)
    {
      if (dataInfo.Tables.Count == 0)
      {
        DataTable table = dataInfo.Tables.Add("Table1");
      }
  
      this.FillDataSet(dataInfo, dataInfo.Tables[0].TableName, this._defaultCommandType, commandText, parameters);
    }
  
    public void FillDataSet(DataSet dataInfo, string tableName, string commandText, IDictionary<string, object> parameters)
    {
      this.FillDataSet(dataInfo, tableName, this._defaultCommandType, commandText, parameters);
    }
  
    public void FillDataSet(DataSet dataInfo, string tableName, CommandType commandType, string commandText, IDictionary<string, object> parameters)
    {
      DbCommand selectComand = this.Connection.CreateCommand();
      selectComand.CommandText = commandText;
      selectComand.CommandType = commandType;
      this.DatabaseAdapter.SelectCommand = selectComand;
      this.DatabaseAdapter.Fill(dataInfo, tableName);
    }
  }
}

Tags:ORM 开发 自己

编辑录入:爽爽 [复制链接] [打 印]
赞助商链接