31 lines
824 B
Plaintext
31 lines
824 B
Plaintext
|
|
|
|||
|
|
using System;
|
|||
|
|
|
|||
|
|
namespace DTS.Storage
|
|||
|
|
{
|
|||
|
|
public class DbTypeAttr : Attribute
|
|||
|
|
{
|
|||
|
|
public string DbType { get; private set; }
|
|||
|
|
internal DbTypeAttr(string attr)
|
|||
|
|
{
|
|||
|
|
DbType = attr;
|
|||
|
|
}
|
|||
|
|
public static string GetDbType(object o)
|
|||
|
|
{
|
|||
|
|
if (o != null)
|
|||
|
|
{
|
|||
|
|
System.Reflection.MemberInfo[] mi = o.GetType().GetMember(o.ToString());
|
|||
|
|
if (mi != null && mi.Length > 0)
|
|||
|
|
{
|
|||
|
|
DbTypeAttr attr = Attribute.GetCustomAttribute(mi[0], typeof(DbTypeAttr)) as DbTypeAttr;
|
|||
|
|
if (null != attr)
|
|||
|
|
{
|
|||
|
|
return attr.DbType;
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
return null;
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
}
|