Active record patter, active record mode

Source: Internet
Author: User

 

The activity record mode is usually used for data-driven applications.ProgramClass of the model database table or view in, with a row of its model database table from the class instance. In this mode, the attributes of the class are mapped to the columns of the corresponding database table.

The instance method of the class performs operations on the database record, while the static method uses the entire table. For example, if the database contains a table named "employee ID uniqueidentifier", a name named "nvarchar (50)", and an employee's table named "salary" as a currency, to implement the activity record mode, you want to create an attribute named "employee ID", "name", and "salary. The employee class will include static methods such as creating, saving, and deleting instance methods, and may include static methods such as deleteall, searching, and findall.

Figure 1The activity record mode is displayed. It provides a simple and intuitive syntax to use data and uses the mappers (O/RM) mode with Multiple object relationships.

Figure 1 activity record mode

// Add Andrew fuller as a new employee Employee EMP = new employee (); EMP. name = "Andrew Fuller"; EMP. salary = 50000.00 m; EMP. create (); // give a 10% raise to all employees employee [] allemployees = employee. findall (); foreach (employee current in allemployees) {current. salary * = 1.10 m; current. save ();}

 

Enterprise Application Architecture

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.