using System;
using System.Reflection;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Configuration;
using System.Data;
using System.Data.SqlClient;
namespace ConsoleApplication1
{
//View
class Program
{
static void Main(string[] args)
{
StudentBll studentBll = new StudentBll();
Student model = studentBll.GetModelByID("3");
Console.WriteLine(model.ID + " " + model.Name + " " + model.Age);
StudentMsgBll studentMsgBll = new StudentMsgBll();
StudentMsg modelMsg = studentMsgBll.GetModelByID("1");
Console.WriteLine(modelMsg.Id + " " + modelMsg.StuName + " " + modelMsg.Age+" "+modelMsg.Address);
Console.WriteLine("请按下键盘任意键退出!");
Console.ReadKey();
}
}
//model
[DBTableName("DBMyTest")]
public class Student
{
[DBField(true)]//调用DBField的有参构造函数,true说明是主键
public int ID { get; set; }
[DBField]//调用DBField的无参构造函数,默认不是主键
public string Name { get; set; }
[
C#反射,特性,数据库结合使用
最新推荐文章于 2021-02-08 10:49:45 发布