定義學生類(student):
class student
public string stu_name
public int stu_age
public string stu_pwd
public classes cls
public stu_cj cj
}定義班級類classes:
class classes
public string cls_name
}定義學生成績類stu_cj:
class stu_cj
public int cj_yw
public int cj_sx
public int cj_yy
}在儲存資料時:
student stud = new student();
stud.stu_name = dr["stu_name"].tostring();//直接儲存
classes cls = new classes(); //需要將其實例化
cls.cls_name = dr["cls_name"].tostring();// 儲存
stud.cls = cls; //在將其儲存在學生類裡面
stu_cj cj = new stu_cj();
cj.cj_yw = int.parse(dr["yuwen"].tostring());
cj.cj_sx = int.parse(dr["shuxue"].tostring());
cj.cj_yy = int.parse(dr["yingyu"].tostring());
stud.cj = cj;
讀取的時候則可以直接讀取:
label1.text = stu.stu_name;
label2.text = stu.cls.cls_name;
label3.text = stu.cj.cj_yw.tostring();
label4.text = stu.cj.cj_sx.tostring();
label5.text = stu.cj.cj_sx.tostring();
C 反射實體類
using system using system.collections.generic using system.text using system.reflection namespace easysrcoreclass.component.utilcomponent 設定屬性值 public...
JPA修改外來鍵關聯的實體類
情況一 不update外來鍵id,update外來鍵關聯的實體物件 不允許設定外來鍵實體關聯物件的id restaurantdto restaurantdto restaurantdao.getbyuserid userid restaurantdto.getlocation setname res...
JSON快速轉C 實體類
首先我們有了json字串。類似於這樣的 然後我們借助外部工具轉換成實體類 public class dogitem public string breed public int count public string twofeet public class root 我用的是這個 來生成實體類。到...