Xcodefactory data access to further simplify!

Source: Internet
Author: User
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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.