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

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

 2008-12-06 10:15:45 来源:WEB开发网   
核心提示: SimpleDbParameterNameMappingusing System;using System.Collections.Generic;using System.Text;using System.Data;namespace Artech.ApplicationBlock.D

SimpleDbParameterNameMapping

using System;
using System.Collections.Generic;
using System.Text;
using System.Data;
namespace Artech.ApplicationBlock.DataMapping
{
  /**//// <summary>
  /// SimpleDbParameterNameMapping defines a simple mapping method between the corresponding parameter name and source culumn name of the table.
  /// </summary>
  public class SimpleDbParameterNameMapping:IDbParameterNameMapping
  {
    IDbParameterNameMapping Members#region IDbParameterNameMapping Members
    /**//// <summary>
    /// Get the source column name based on the parameter name of the related stored procedure.
    /// </summary>
    /// <param name="patameterName">The parameter name of the corresponding stored procedure.</param>
    /// <returns>The source column name corresponding to the parameter name.</returns>
    public string GetSourceCoulmnName(string patameterName)
    {
      //@p_abc_def|o_abc_def=>ABC_DEF
      return patameterName.Substring(3, patameterName.Length - 3).ToUpper();
    }
    /**//// <summary>
    /// Get the source parameter name based on the source column name.
    /// </summary>
    /// <param name="columnName">The source column name corresponding to the parameter name.</param>
    /// <param name="rowVersion">The data row version of the source solumn conressponding to the parameter.</param>
    /// <returns>The parameter name of the corresponding stored procedure.</returns>
    public string GetParameterName(string columnName, DataRowVersion rowVersion)
    {
      //ABC_DEF =>@p_abc_def|o_abc_def
      string prefix = "@p";
      if (rowVersion == DataRowVersion.Original)
      {
        prefix = "@o";
      }
      return string.Format("{0}_{1}", prefix, columnName.ToLowerInvariant());
    }
    #endregion
  }
}

上一页  2 3 4 5 6 7 8 9 10  下一页

Tags:ORM 开发 自己

编辑录入:爽爽 [复制链接] [打 印]
[]
  • 好
  • 好的评价 如果觉得好,就请您
      0%(0)
  • 差
  • 差的评价 如果觉得差,就请您
      0%(0)
赞助商链接