Step by step teach you how to use the agileeas. net base class library for application development-basics-use UDA to manipulate SQL statements

Source: Internet
Author: User

PreviousArticleBased on agileeas. NET platform basic library for application development-the general description and Data Definition of the data tables and part of the data involved in this case, this article will start from the most basic business, data access-SQL statement operation starts.

In agileeas. in the. NET platform, data access is encapsulated and called UDA (Unified Data Access. for more information about the. NET platform UDA, see agileeas. net.

Two APIs idataconnection and idataaccessor are defined in UDA. idataconnection provides the idataaccessor data connection environment to perform SQL statement operations.

Process

If you use UDA for database operations, see the following process:

ConversionProgramCodeThat is:

Public VoidFullflow (){StringDbconnectiong =""; Idataconnection dataconnection =NewOledbconnection (dbconnectiong); idataaccessor dataaccessor = dataconnection. createdataaccessor (); dataconnection. open ();Try{// Do...}Finally{Dataconnection. Close ();}}
 
 
The idataconnection object has the built-in function of automatically managing the opening and closing of connections. The procedure for enabling and disabling connections can just be simplified:

Data operation method:

Idataaccessor provides two different overload Methods: Query and execute. query is used to implement data query services. Execute is used to update and modify operations, the queryscalar, querydatareader, querydataset, querydatatable, querydictionary, and querylist statements are derived based on the query method. Each derivative method corresponds to a return type of the query overload, in UDA, data is returned by oject, idatareader, dataset, able, idictionary, and ilist respectively. Two special return results: idictionary and ilist, idictionary is used to return the key-Value Pair (field name/field value) of a query record, and ilist is used to return the value of the first column of the query record. Execute is nothing special.

Case study:

The examples included in this article demonstrate the UDA business except transactions after processing. For each data operation statement, I write a specific example method. Below I paste the main method code:

     Static   Void Main ( String [] ARGs) {system. Console. writeline (" Example of using the agileeas. NET platform UDA component, press the task key to start... "); System. Console. Read (); system. Console. writeline ("Example of using idatareader: "); New Udaquery (). demegetdatareader (); system. Console. writeline (" Start by pressing the task key... "); System. Console. Read (); system. Console. writeline (" Example of using idataset: "); New Udaquery (). demegetdataset (); system. Console. writeline (" Start by pressing the task key... "); System. Console. Read (); system. Console. writeline (" Example of using idatatable: "); New Udaquery (). demegetdatatable (); system. Console. writeline ("Start by pressing the task key... "); System. Console. Read (); system. Console. writeline (" Example of Using Dictionary: "); New Udaquery (). demegetdictionary (); system. Console. writeline (" Start by pressing the task key... "); System. Console. Read (); system. Console. writeline (" Example of using list: "); New Udaquery (). demegetlist (); system. Console. writeline (" Start by pressing the task key... "); System. Console. Read (); system. Console. writeline (" Example of using scalar: "); New Udaquery (). demegetscalar (); system. Console. writeline (" Start by pressing the task key... "); System. Console. Read (); system. Console. writeline (" Example of data update: "); New Udaexecute (). demeexecute (); system. Console. writeline (" Press the task key to end. "); System. Console. Read ();}
 
 

For other references, see the udaquery and udaexecute classes in the source code. The running effect of the example is as follows:

In this example, we will introduce the datareader delegation and transaction delegation of UDA in agileeas. net.

For the structure of the data table involved in this example, refer to the data table structure based on agileeas. NET platform basic library for application development-General description and data definition, for data object model definition files, documents, DDL scripts download: Workshop.

 

Link

Agileeas. NET platform development guide-series Directories

Introduction to agileeas. NET application development platform-Index

Agileeas. NET platform application development tutorial-case plan

Step by step teach you how to use the agileeas. net base class library for application development-series directory

Official website of agileeas. net

Agile Software Engineering Lab

QQ: 116773358

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.