Attribute学习:SqlCommandMethodAttribute 荣

using System;
using System.Data;

namespace WebApplication1
{
 /// <summary>
 ///  方法的属性,存储要生成Command对象的类型与CommandText值。
 /// </summary>
 [AttributeUsage(AttributeTargets.Method)]
 public sealed class SqlCommandMethodAttribute : Attribute
 {
  /// <summary>
  /// command对象的CommandText值
  /// </summary>
  private string commandText;

  /// <summary>
  /// command对象的泪习惯
  /// </summary>
  private CommandType commandType;

  public SqlCommandMethodAttribute(CommandType commandType, string commandText)
  {
   this.commandText = commandText;
   this.commandType = commandType;
  }

  public SqlCommandMethodAttribute(CommandType commandType) : this(commandType, null)
  {
  }

  public string CommandText
  {
   get
   {
    return commandText == null ? string.Empty : commandText;
   }
   set
   {
    commandText = value;
   }
  }

  public CommandType Commondtype
  {
   get
   {
    return commandType;
   }
   set
   {
    commandType = value;
   }
  }
 }
}

原文地址:https://www.cnblogs.com/admin11/p/200264.html