Easy to get data access layer 1

xiaoxiao2021-03-06  69

Easily get the data access layer Yuhonglai [original] The method of implementing the implementation, you can freely release you from SQL's add, delete, Update, and SELECT. 1. Entity class 2. Access classes are now tblperson (Perid, Perne, Pergender, PEROLD, Perid, Pernation) physical classes --------- iDNameGenderoldNation Access base class DataOper ---------- Shared deleteshared Addshared Updateshared SELECT Access Class Personoper: DataOper -------------------- Shared getAllshared getPersonbyidshared getPersonBynameshared get ... imports the information of the database table to DB.xml files In accordance with DB.XML files, generate physical classes such as the top of the TBLPerson table corresponding to a table name Name DBNAME KEY SEED TYPE ------------------- ----------------- iD Perid 1 1 IntegerName Perid 0 0 Stringgender Pergender 0 0 Booleanold Perold 0 0 IntegerNation Pernation 0 0 String will convert DataSet returned from the database into physical classes, if Write in general way: DS = cmd.execute ("Select * from tblperson where id = 1") DIM P as new personp.id = ctype (DS.TABLES (0) .ROWS (0) .Item ("Perid" ), Integer) p.Name = ... p.gender = ... p.old = ... p.NATION = ... a table conversion is also good, then if there is dozens of patch efficiency Underground, there is another generic method, using the reflection function provided by .NET! The reflection function provided by .NET can dynamically access the classes in the case of a known method or attribute.

转载请注明原文地址:https://www.9cbs.com/read-119700.html

New Post(0)