日韩无码专区无码一级三级片|91人人爱网站中日韩无码电影|厨房大战丰满熟妇|AV高清无码在线免费观看|另类AV日韩少妇熟女|中文日本大黄一级黄色片|色情在线视频免费|亚洲成人特黄a片|黄片wwwav色图欧美|欧亚乱色一区二区三区

RELATEED CONSULTING
相關(guān)咨詢
選擇下列產(chǎn)品馬上在線溝通
服務(wù)時(shí)間:8:30-17:00
你可能遇到了下面的問題
關(guān)閉右側(cè)工具欄

新聞中心

這里有您想知道的互聯(lián)網(wǎng)營(yíng)銷解決方案
自己寫數(shù)據(jù)庫(kù)訪問ORM

 下面看一個(gè)例子:

成都創(chuàng)新互聯(lián)專注為客戶提供全方位的互聯(lián)網(wǎng)綜合服務(wù),包含不限于成都網(wǎng)站設(shè)計(jì)、成都網(wǎng)站建設(shè)、東源網(wǎng)絡(luò)推廣、成都小程序開發(fā)、東源網(wǎng)絡(luò)營(yíng)銷、東源企業(yè)策劃、東源品牌公關(guān)、搜索引擎seo、人物專訪、企業(yè)宣傳片、企業(yè)代運(yùn)營(yíng)等,從售前售中售后,我們都將竭誠(chéng)為您服務(wù),您的肯定,是我們最大的嘉獎(jiǎng);成都創(chuàng)新互聯(lián)為所有大學(xué)生創(chuàng)業(yè)者提供東源建站搭建服務(wù),24小時(shí)服務(wù)熱線:18980820575,官方網(wǎng)址:www.cdcxhl.com

現(xiàn)在有一個(gè)用戶信息的表:E-R圖如下:

要實(shí)現(xiàn)該表的數(shù)據(jù)庫(kù)新增、修改、查詢功能,需要實(shí)現(xiàn)下面兩個(gè)業(yè)務(wù)類:

 
 
 
 
  1. using Csla; 
  2. using IF.CslaCore; 
  3. using IF.OrmCore.DataSchema; 
  4. using System; 
  5. using System.Collections.Generic; 
  6. using System.ComponentModel; 
  7. using System.Linq; 
  8. using System.Text; 
  9. using System.Threading.Tasks; 
  10.  
  11. namespace IF.SysUser.Business 
  12.     [Serializable] 
  13.     [TableClass(FriendlyName="用戶信息表",TableName="SYS_USER")] 
  14.     public class SysUser : IfBusiness 
  15.     { 
  16.         private static readonly PropertyInfo SUR_IDProperty = RegisterProperty(c => c.SUR_ID); 
  17.  
  18.         [DisplayName("SUR_ID")] 
  19.         [FieldDescription(IsPrimaryKey=true,ColumnName="SUR_ID",FriendlyName="SUR_ID",NeedUpdate=true)] 
  20.         public string SUR_ID { get; set; } 
  21.  
  22.         private static readonly PropertyInfo UserNameProperty = RegisterProperty(c => c.UserName); 
  23.         [DisplayName("登錄名")] 
  24.         [FieldDescription(ColumnName="SUR_USERNAME",FriendlyName="登錄名",NeedUpdate=true)] 
  25.         public string UserName { get; set; } 
  26.  
  27.  
  28.         private static readonly PropertyInfo NameProperty = RegisterProperty(c => c.Name); 
  29.         [DisplayName("姓名")] 
  30.         [FieldDescription(ColumnName="SUR_NAME",FriendlyName="姓名",NeedUpdate=true)] 
  31.         public string Name { get; set; } 
  32.  
  33.         private static readonly PropertyInfo PasswordProperty = RegisterProperty(c => c.Password); 
  34.         [DisplayName("密碼")] 
  35.         [FieldDescription(ColumnName="SUR_PASSWORD",FriendlyName="密碼",NeedUpdate=true)] 
  36.         public string Password { get; set; } 
  37.  
  38.         private static readonly PropertyInfo LoginMacProperty = RegisterProperty(c => c.LoginMac); 
  39.         [DisplayName("登錄Mac地址")] 
  40.         [FieldDescription(ColumnName="SUR_LOGIN_MAC",FriendlyName="登錄Mac地址",NeedUpdate=true)] 
  41.         public string LoginMac { get; set; } 
  42.  
  43.         private static readonly PropertyInfo LoginIPProperty = RegisterProperty(c => c.LoginIP); 
  44.         [DisplayName("登錄IP")] 
  45.         [FieldDescription(ColumnName="SUR_LOGIN_IP",FriendlyName="登錄IP",NeedUpdate=true)] 
  46.         public string LoginIP { get; set; } 
  47.  
  48.  
  49.         private static readonly PropertyInfo LoginTimeProperty = RegisterProperty(c => c.LoginTime); 
  50.         [DisplayName("登錄時(shí)間")] 
  51.         [FieldDescription(ColumnName="SUR_LOGIN_TIME",FriendlyName="登錄時(shí)間",NeedUpdate=true)] 
  52.         public DateTime? LoginTime { get; set; } 
  53.  
  54.         private static readonly PropertyInfo LogoutTimeProperty = RegisterProperty(c => c.LogoutTime); 
  55.         [DisplayName("登出時(shí)間")] 
  56.         [FieldDescription(ColumnName="SUR_LOGOUT_TIME",FriendlyName="登出時(shí)間",NeedUpdate=true)] 
  57.         public DateTime? LogoutTime { get; set; } 
  58.  
  59.         private static readonly PropertyInfo LoginFailTimeProperty = RegisterProperty(c => c.LoginFailTime); 
  60.         [DisplayName("登錄失敗時(shí)間")] 
  61.         [FieldDescription(ColumnName="SUR_LOGIN_FAIL_TIME",FriendlyName="登錄失敗時(shí)間",NeedUpdate=true)] 
  62.         public DateTime? LoginFailTime { get; set; } 
  63.  
  64.         private static readonly PropertyInfo LoginFailCountProperty = RegisterProperty(c => c.LoginFailCount); 
  65.         [DisplayName("登錄失敗次數(shù)")] 
  66.         [FieldDescription(ColumnName="SUR_LOGIN_FAIL_COUNT",FriendlyName="登錄失敗次數(shù)",NeedUpdate=true)] 
  67.         public Int32? LoginFailCount { get; set; } 
  68.  
  69.  
  70.         private static readonly PropertyInfo LockFGProperty = RegisterProperty(c => c.LockFG); 
  71.         [DisplayName("是否鎖定")] 
  72.         [FieldDescription(ColumnName="SUR_LOCK_FG",FriendlyName="是否鎖定",NeedUpdate=true)] 
  73.         public bool? LockFG { get; set; } 
  74.  
  75.         private static readonly PropertyInfo DisableFGProperty = RegisterProperty(c => c.DisableFG); 
  76.         [DisplayName("是否有效")] 
  77.         [FieldDescription(ColumnName="SUR_DISABLE_FG",FriendlyName="是否有效",NeedUpdate=true)] 
  78.         public bool? DisableFG { get; set; } 
  79.  
  80.  
  81.         #region 通用字段 
  82.  
  83.         private static readonly PropertyInfo CreateTimeProperty = RegisterProperty(c => c.CreateTime); 
  84.         [DisplayName("創(chuàng)建時(shí)間")] 
  85.         [FieldDescription(ColumnName="CreateTime",FriendlyName="創(chuàng)建時(shí)間",NeedUpdate=true)] 
  86.         public override DateTime? CreateTime { get; set; } 
  87.  
  88.         private static readonly PropertyInfo LastUpdateTimeProperty = RegisterProperty(c => c.LastUpdateTime); 
  89.         [DisplayName("***修改時(shí)間")] 
  90.         [FieldDescription(ColumnName="LastUpdateTime",FriendlyName="***修改時(shí)間",NeedUpdate=true)] 
  91.         public override DateTime? LastUpdateTime { get; set; } 
  92.  
  93.  
  94.  
  95.         public override void SetPrimaryKey(string key) 
  96.         { 
  97.             SUR_ID = key; 
  98.         } 
  99.         #endregion 
  100.     } 
  101.  
  102.     [Serializable] 
  103.     public class SysUserList : IfBusinessList 
  104.     { } 

現(xiàn)在就可以工作了:

全表檢索數(shù)據(jù)方法:

 
 
 
 
  1. SysUserList selData = SysUserList.Fetch(); 

向數(shù)據(jù)庫(kù)新增一條數(shù)據(jù):

 
 
 
 
  1. SysUser.Business.SysUser user = new SysUser.Business.SysUser(); 
  2. user.UserName= "inaction"; 
  3. user.Name = "流砂"; 
  4. user.Password= "superman"; 
  5. selData.Add(user); 
  6. selData.Save(); 

向數(shù)據(jù)庫(kù)修改數(shù)據(jù):

 
 
 
 
  1. var user = SysUserList.Fetch(c => c.UserName == "inaction"); 
  2. user.Password = "123456"; 
  3.  SysUserList list = new SysUserList { user }; 
  4.  list.Save(); 

以上代碼就實(shí)現(xiàn)了對(duì)密碼的修改。

特別說明:目前IF 只能通過SysUserList對(duì)象的Save方法保存數(shù)據(jù)。以后會(huì)實(shí)現(xiàn)通過業(yè)務(wù)類自身Save方法保存數(shù)據(jù)。


網(wǎng)頁(yè)名稱:自己寫數(shù)據(jù)庫(kù)訪問ORM
本文路徑:http://m.5511xx.com/article/cdjdhpo.html