.net简单的三层实现功能
在网上看到别人的代码,写下来留着看,欢迎各位指教,有没有工厂模式的学习资料啊,留下给小弟学习学习.
首先写个Model类,实现业务实体,我的比较简单,只有三个字段
View Code
1 public class LoginModel
2 {
3 #region
4
5 private int _AdminId;
6 private string _AdminUID;
7 private string _AdminPWD;
8
9 public string AdminPWD
10 {
11 get { return _AdminPWD; }
12 set { _AdminPWD = value; }
13 }
14
15 public int AdminId
16 {
17 get { return _AdminId; }
18 set { _AdminId = value; }
19 }
20
21
22 public string AdminUID
23 {
24 get { return _AdminUID; }
25 set { _AdminUID = value; }
26 }
27
28 #endregion
29 }
2.创建一个DBHelp类,实现SQLServer数据库访问
View Code
1 public class DBHelp
2 {
3 private static readonly string connectionString = ConfigurationManager.ConnectionStrings["connstr"].ConnectionString.ToString();
4 private static readonly string providerName = "System.Data.SqlClient";
5
6 /// <summary>
7 /// GetConnection 用于获取连接数据库的 connection 对象
8 /// </summary>
9 /// <returns></returns>
10 private static DbConnection GetConnection()
11 {
相关新闻>>
- 发表评论
-
- 最新评论 更多>>