據(jù)備份/My%20Knowledge/temp/45cf6017-dac2-43aa-bc45-21ff59dec8f4_128_files/3cc024ee-a1aa-428f-a3dd-0dbd74f5ecc8.png)


<connectionStrings><add name="StudentM" connectionString="Database=StudentM;Server=.;Integrated Security=false;Uid=sa;PassWord=123;" providerName="System.Data.SqlClient"/></connectionStrings>
public enum DataBaseEnum{//改這個(gè)地方為Web.config的數(shù)據(jù)庫節(jié)點(diǎn)名,如果多個(gè)數(shù)據(jù)庫就在后面加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(){//設(shè)主鍵PrimaryKey = "AdminId";//數(shù)據(jù)庫名為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是一個(gè)對象,所有的增刪改查的方法什么的都放在BaseDAL//用靜態(tài)是因?yàn)橥ㄟ^類去調(diào)用m_AdminInfo就更簡單,不用實(shí)例化public static BaseDAL<AdminInfo> m_AdminInfo = new BaseDAL<AdminInfo>();}}新聞熱點(diǎn)
疑難解答
圖片精選