标签:



<connectionStrings> <add name="StudentM" connectionString="Database=StudentM;Server=.;Integrated Security=false;Uid=sa;Password=123;" providerName="System.Data.SqlClient"/> </connectionStrings>
public enum DataBaseEnum
{
//改这个地方为Web.config的数据库节点名,如果多个数据库就在后面加XXX=2
StudentM = 1
}
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
//引入类库
using com.Model.Base;
namespace Model.StudentM
{
//继承BseModel(命名空间为com.Model.Base的Model.Base的类库)
public class AdminInfo: BaseModel
{
public AdminInfo()
{
//设主键
PrimaryKey = "AdminId";
//数据库名为DataBaseEnum下的StudentM
DataBaseName = DataBaseEnum.StudentM;
}
//写所有的列名字段,记得类型要一致
public int AdminId
{
//get和set分别表示可读和可写
get;
set;
}
public string UserName
{
get;
set;
}
public string Pwd
{
get;
set;
}
}
}
//记得引入
using Model.StudentM;
using com.DAL.Base;
namespace Dal.StudentM
{
public class AdminInfoDal
{
//BaseDAL是一个对象,所有的增删改查的方法什么的都放在BaseDAL
//用静态是因为通过类去调用m_AdminInfo就更简单,不用实例化
public static BaseDAL<AdminInfo> m_AdminInfo = new BaseDAL<AdminInfo>();
}
}
标签:
原文地址:http://www.cnblogs.com/xxsy/p/4684661.html