<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=2StudentM = 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下的StudentMDataBaseName = 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>();}}
新闻热点
疑难解答