TableAttribute.cs
using System;
using System.Collections.Generic;
using System.Text;

namespace Common
{
    [AttributeUsage(AttributeTargets.Class)]
    
public class TableAttribute : Attribute
    {
        
private string m_name;
        
private string m_keys;

        
public TableAttribute(string name, string primaryKeys)
        {
            
this.m_name = name;
            
this.m_keys = primaryKeys;
        }

        
public string Name
        {
            
get { return m_name; }
            
set { m_name = value; }
        }

        
public string PrimaryKeys
        {
            
get { return m_keys; }
            
set { m_keys = value; }
        }
    }
}
ColumnAttribute.cs
using System;

namespace Common
{
    [AttributeUsage(AttributeTargets.Property)]
    
public class ColumnAttribute : Attribute
    {
        
private string name;

        
public ColumnAttribute(string name)
        {
            
this.name = name;
        }

        
public string Name
        {
            
get { return name; }
            
set { name = value; }
        }
    }
}
User.cs
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace Common
{
    [Table(
"T_Bas_User""Id")]
    
public class User
    {
        
private int id;
        
private string name;
        
private bool isAdmin;
        
private decimal salary;
        
private DateTime birthday;

        [Column(
"Id")]
        
public int Id
        {
            
get { return this.id; }
            
set { this.id = value; }
        }

        [Column(
"FullName")]
        
public string Name
        {
            
get { return this.name; }
            
set { this.name = value; }
        }

        [Column(
"IsAdmin")]
        
public bool IsAdmin
        {
            
get { return this.isAdmin; }
            
set { this.isAdmin = value; }
        }

        [Column(
"Salary")]
        
public Decimal Salary
        {
            
get { return this.salary; }
            
set { this.salary = value; }
        }

        [Column(
"Birthday")]
        
public DateTime Birthday
        {
            
get { return this.birthday; }
            
set { this.birthday = value; }
        }
    }
}

相关文章:

  • 2022-02-13
  • 2021-11-14
  • 2021-05-01
  • 2022-12-23
  • 2021-12-05
  • 2021-07-12
  • 2021-07-05
  • 2022-12-23
猜你喜欢
  • 2021-08-30
  • 2021-09-24
  • 2022-12-23
  • 2021-09-21
  • 2022-12-23
  • 2021-09-25
  • 2022-12-23
相关资源
相似解决方案