在前一篇文章中介绍到了Attribute的一些基本概念,至于它的一些具体的用法还没有意义解释,现在就针对Attribute的自定义问题,通过实例来加强了解吧!
(一)自定义部分
<span style="font-size:18px;">using System;
usingSystem.Collections.Generic;
usingSystem.Diagnostics;
using System.Linq;
usingSystem.Runtime.InteropServices;
using System.Text;
usingSystem.Reflection;
using System.Data;
namespaceConsoleApplication1
{
#region ORMapping
[AttributeUsageAttribute(AttributeTargets.Class, Inherited = false,AllowMultiple = false)]
public class TableAttribute : Attribute
{
//保存表名的字段
private string _tableName;
public TableAttribute()
{
}
public TableAttribute(string tableName)
{
this._tableName = tableName;
}
/// <summary>
/// 映射的表名(表的全名:模式名.表名)
/// </summary>
public string TableName