Petapoco (1)

Source: Internet
Author: User

1.ORMSummary

1.1.ORMIntroduction

Orm object-relational ing (ORM) is developed with the development of object-oriented software development methods. Object-Oriented development is the mainstream development method in today's enterprise-level application development environment. Relational databases are the mainstream data storage systems that permanently store data in enterprise-level application environments. Objects and relational data are two forms of business entities. business entities are represented as objects in the memory and relational data in the database. Objects in the memory have associations and inheritance relationships. In the database, relational data cannot directly express many-to-many associations and inheritance relationships. Therefore, object-relational ing (ORM) systems generally exist in the form of middleware.ProgramMappings between objects and relational database data.

Object-Oriented development is based on the basic principles of Software Engineering (such as coupling, aggregation, and encapsulation), while relational databases are developed from mathematical theories, there are significant differences between the two sets of theories. To solve this mismatch, the object link ing technology emerged.

Let's start with O/R. The letter O originated from "object", while R came from "relational ). Objects and relational databases exist in almost all programs. In the business logic layer and user interface layer, We are object-oriented. When the object information changes, we need to save the object information in the relational database.

If you open your latest program (such as petshop4.0), check the Dal (database access layer)CodeYou will certainly see many similar general models. Let's take the method of saving objects as an example. You pass in an object, add sqlparameter to the sqlcommand object, map all attributes to the object, set the commandtext attribute of sqlcommand as the stored procedure, and then run sqlcommand. This code must be repeatedly written for each object. In addition, is there a better way? Yes. Introduce an O/R Mapping. Essentially, an O/R Mapping will generate a dal for you. It is better to use o/R Mapping than to write the Dal code by yourself. You use o/R Mapping to save, delete, and read objects. O/R Mapping is responsible for generating SQL statements. You only need to care about objects.

1.2.PetapocoIntroduction

Petapoco is a tiny, fast, micro-ORM for a single file that can run on. NET and mono platforms. The term object/relational ing (ORM) represents a technology used to map objects represented by the object model to the SQL-based relational model data structure.

Petapoco is a lightweight object relational Er (ORM, object relational mapper) for. NET applications ). Unlike the fully functional ORM (such as Nhibernate or Entity Framework), petapoco focuses more on ease of use and performance than on rich features. To use petapoco, you only need to introduce a C # file. You can use strong poco (plain old CLR object) and support classes generated using T4 templates.

In today's enterprise environment, using object-oriented software and relational databases together may be quite troublesome and time-consuming. Petapoco is not just a management service. net class to database table ing (including.. Net ing between data types and SQL data types. It also provides data query and data acquisition methods, which can greatly reduce the manual use of SQL and ADO during development.. net.

The goal of petapoco is mainly to use it for programming tasks related to data persistence. It can free developers from the boring preparation of SQL statements, the liberated energy allows developers to invest in the implementation of business logic. For data-centric programs, developers often use stored procedures in databases to implement business logic. In this case, petapoco may not be the best solution, but for those based on. and can realize the application of the middle layer of the OO business model and business logic. petapoco is the most useful. Petapoco can help users eliminate or wrap the SQL code for specific vendors, and help users convert the result set from table-based representation into a series of objects.

Petapoco functions include:

1) it can work with SQL Server, SQL Server ce, MySQL, PostgreSQL, and Oracle databases.

2) Multiple auxiliary methods for insert/delete/update/Save and isnew are included.

3) support for simple transactions

4) for paging requests, the total number of records is automatically calculated and a specific page is obtained.

5) parameter substitution is supported. You can capture named parameters (named parameters) from object attributes)

6) includes an SQL builder class that consumes a small amount of resources.

7) partial record updates

8) includes T4 templates, which can be used to generate poco classes based on the database structure.

In terms of performance, petapoco is second only to dapper, and its speed is only slightly inferior to that of the manually-encoded data access layer (DAL, data access layer ). In addition, because petapoco is an open-source project, it is easy to add conditions to process specific situations such as spatial data.

Recently, with the release of many open-source projects, micro-ORM has become a popular trend. Other well-known projects for. Net include dapper and massive. Compared with fully functional Orm, micro-ORM is simpler and more efficient. Micro-ORM usually requires developers to manually write SQL statements instead of completely dynamic generation. They also do not need lengthy ing files, because for maintenance and debugging, those ing files only make the process monotonous.

1.3.Get petapoco

1) • nuget-http://nuget.org/List/Packages/PetaPoco

2) • GitHub-https://github.com/toptensoftware/petapoco

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.