Today, several methods are added for the dataentrance static class. These methods further simplify the imperative access to the database. The newly added method signature is as follows: public static void insert (Object OBJ, idbtransaction trans );
Public static object insertreturnidentity (Object OBJ, idbtransaction trans );
Public static void insertbatch (arraylist objs, idbtransaction trans );
Public static void insertbatch (object [] objs, idbtransaction trans );
Public static void Update (Object OBJ, idbtransaction trans );
Compared with methods with the same name, these methods have a "type objtype" parameter missing. In fact, this parameter can be obtained through OBJ reflection query. Therefore, the new method ignores this parameter, for compatibility with earlier versions, the old method with the same name is not removed from dataentrance.
Now, let's take an example of inserting a customer into the database to see which methods are available and how simple these methods are. Assume that a customer instance already exists: Customer cum = new customer ();
// Assign a value to the customer Member
(1) Method 1: String connstr =;
Idbaccesser dbaccesser = new customersqldealer ();
Dbaccesser. insert (cum, null );
(2) Method 2: idbaccesser dbaccesser = dataentrance. createdbaccesser (typeof (customer ));
Dbaccesser. insert (cum, null );
(3) method 3: dataentrance. insert (typeof (customer), cum, null );
(4) Method 4: dataentrance. insert (cum, null );
The simplest of course is the fourth method. We strongly recommend that you do not use the first method. The reason is already described in the previous blog.
Xcodefactory learning directory