听说很多ORM框架都是用XML映属性和表字段的关系,现在看来用C#里的attribute好像也很方便。
namespace ConsoleApplication4
{
class Class1
{
static void Main()
{
person p = new person();
p.Name = "韩梅梅";
p.Sex = "女";
p.Age = 14;
DBAccess dba = new DBAccess();
dba.AddPerson(p);//
}
}
[AttributeUsage(AttributeTargets.Property,AllowMultiple=true,Inherited=false)]
public class DataFieldAttribute: Attribute
{
string _FieldName;
string _FieldType;
public DataFieldAttribute(string fieldName, string fieldType)
{
_FieldName = fieldName;
_FieldType = fieldType;
}
public string FieldName