Pdf.net SOD Open Source Framework red envelopes delivery Activities && Beginners Quick Start Guide

Source: Internet
Author: User
Tags ticket connectionstrings

First, the origin of the frameworkQuick Start
For more information about frames, see the framework's official homepage!

The idea of this framework is to draw on the Java platform's hibernate and IBatis, with the features of ORM and Sql-map, as well as reference to later. NET LINQ (This framework was formed in 2006, when it was not yet heard of LINQ) using styles, OQL query expressions were designed. The concept of this framework is universal and can be ported to the Java platform and is now available only. NET platform, the framework is named

Pdf.net

From 2013.10.1 onwards, the original pdf.net will be renamed

Sodone sql-map,orm,data Control Framework


The original pdf.net framework will be a full-featured enterprise development Framework, and the sod framework will be the "Data development framework" under the Pdf.net development framework

Pdf.net Open Source History:

    1. 2010.2--PDF.NET3.0 member Release version
    2. 2010.5--pdf.net3.5 member Release version
    3. 2011.3--PDF.NET4.0 member Release version
    4. 2011.9--pdf.net Ver 3.0 Open Source section before gift: pdf.net (Pwmis Data Development Framework) V3.0 version Open source HTTP://WWW.CNBLOGS.COM/BLUEDOCTOR/ARCHIVE/2011/09/29/2 195751.html
    5. 2012.9--pdf.net Ver 4.5 Open Source section before gift: pdf.net (Pwmis Data Development Framework) V4.5 version Open source
    6. 2014.1--pdf.net Ver 5.1 The last article before the Spring Festival, crud Code Farm special benefits: Pdf.net's sod Version 5.1.0 Open Source release (and renamed)
    7. 2015.2--pdf.net SOD Ver5.1 Spring, 2015 opening: pdf.net SOD Ver 5.1 fully open source

Open Source Agreement:

    • Framework Class Library Open source agreement: The LGPL agreement, which allows commercial use, but is limited to the inclusion of class library release, the source code should not be sold as a commercial sales distribution, for details, please see the official description of the agreement.
    • Framework Support Tools Open Source agreement: The GPL is not used for distribution and modification of commercial sales, if you want to use it for commercial purposes or closed source, please purchase the license separately, please see the official description of this agreement for details.
    • Framework-related Examples demo Open source agreement: Using the MIT protocol, you can freely modify the use, see the official description of the agreement for details.

Note: The framework's support tools refer to integrated development tools, which can be connected to various databases for querying, generating entity classes, Sql-map Dal and sqlmap.config files.

Second, open source donation account

The figure on the right is a two-dimensional code donation method

Thanks to all PDFs. NET Framework of member friends enthusiastic donations, and for the framework of continuous improvement and promotion made outstanding contributions! 2015 Spring Festival, send red envelopes to everyone!

Iii. Quick Start: 3.1, overview

The sod frame is divided into 3 parts:

    1. Sql-map
    2. Orm
    3. Data Control

3.2, "SqlHelper" Foundation

These three parts are based on the Adohelper component, it complies with the MS Daab standard, so people familiar with SqlHelper should be easy to get started, the following examples:

Adohelper helper=new  SQL Server ();D ataset ds=helper. ExecuteDataset ("Data source=.;i Nitial catalog=localdb;integrated security=True ",      CommandType.Text,      * from Table_user");

Adohelper is an abstract class, so it can be instantiated into other database access classes, such as continuing the following code:

helper=New//Accessdatabase accesses the class DataSet dsacc=helper. ExecuteDataset ("Provider=microsoft.ace.oledb.  12.0; Jet oledb:engine type=6;D ata source=D:\Data\SuperMarket.accdb ",        CommandType.Text,        * from Table_user ");

In Pwmis. Core.dll Sod Core Library, built-in SQLSERVER,SQLSERVERCE,ACCESS,ORACLE,OLEDB,ODBC and other common database access class provider.

Each time in the program to specify the connection string and query command type, the benefit is "with", thread safety, anytime and anywhere "SqlHelper", but the downside is code redundancy, so you can put the data access class type and connection string into the application configuration file (app. config/ Web. config):

< connectionStrings >    <  name= "Accessdb"
  connectionString= "provider=microsoft.ace.oledb.12.0; Jet Oledb:engine Type=6;data source= | datadirectory| SUPERMARKET.ACCDB "
  providerName= "Access"/></connectionStrings >

In the connection configuration above, providerName= "Access" means that this will be the access provider for the Access database with the SOD framework, if providerName= SQL Server will use the SQL Server provider.

In the case of a data access provider other than the SOD core program, you need to use a connection configuration in the following format:

<name= "Default"   connectionString= "server=10.0.0.1; User id=pdfnet;password=pdfnet2015; Charset=utf8;database=test; Allow Zero datetime=true "  providerName=" Pwmis. Dataprovider.data.mysql,pwmis. Mysqlclient "/>

This configuration indicates that the assembly that contains the SOD data access driver named Default is Pwmis. MySqlClient.dll, the full name of the provider is Pwmis. DataProvider.Data.MySQL.

Note: The connection string in the Web. config file supports | datadirectory| The path format.

Once you have configured the database connection information, you can use it in your program as follows:

using Pwmis. Dataprovider.adapter; // ... .. Adohelper accessdb1=mydb.instance; // application configuration File connection configuration section The last data connection configuration // Connection string Name
// Connection string Name BOOL typeof // flag=true;
BOOL typeof // flag2=true;

Note the Mydb.instance object in the example, which is the default data access class used by the system, and it always reads the last data connection configuration of the application configuration File connection configuration section, which is a static simple interest object, do not use it in a transaction, and it is possible to use it anywhere, in the first place, However, it is still not recommended that you use the Mydb.instance adohelper Singleton object in a multithreaded environment and recommend ACCESSDB2 Adoheper instantiation.

3.3, Summary:

The above illustrates the use of the most basic data access component of the Pdf.net sod framework Adohelper, but this is also a lot of novice friends are not very clear of the place, especially the Mydb.instance single-object easy to abuse, must master.

Sod frame Most of the cases, only need to carry out the above data connection configuration, can run the code smoothly, compared to the Entity Framework configuration, is not much simpler?

See here, I think you should get started, below let us briefly explore the sod frame of a approximate.

----

Iv. Sql-map

Have you ever or seen a project done by someone else,

    • A large number of splicing SQL statements, or SQL parameterized queries dragged long and cumbersome code, and even SQL fly?
    • Isn't it very painful to maintain such code?
    • Is it a bit of a waste of life to write crud code like this every day?

Now, you can put all the SQL statements in a single configuration file, centrally manage and maintain your query program, and even this job you can throw to the DBA!

This feature is similar to the Java realm famous IBatis and ported to. Net Mybatis.net, however, Sql-map removes their long configuration and uses the tool to generate code automatically, so that writing the DAL data access layer does not require writing a line of code , please refer to the following article:

Pdf.net's sql-map using illustrated tutorials

For more content, you can also refer to the SOD Framework official blog:

(Pdf.net framework example) mapping stored procedures to entity classes Deep Blue 2011-08-18 17:25 read: 1748 comments: 6

Use XSD to write an XML file with smart hints (as an instance of Sql-map script) deep Blue 2011-05-13 12:17 read: 1609 comments: 7

Pdf. NET (Pwmis Data Development Framework) SQL-MAP objectives and specifications Deep Blue 2011-05-07 00:05 read: 937 comments: 1

Abstract SQL Query: The use of sql-map technology Deep Blue doctor 2011-05-06 11:59 read: 3598 comments: 21

Using Oql+sqlmap to solve the query problem of ORM Multi-table complex deep Blue doctor 2011-02-25 19:08 read: 928 comments: 0

Pdf. NET Data development framework sql-map using stored procedures Deep Blue doctor 2010-07-03 23:31 read: 2386 comments: 4

Five, ORM

The SOD framework has invented the unique ORM query Language OQL, which basically covers most of the functions of the SQL92 standard, allowing you to use "Object-based SQL" in the VS IDE. There is no more ORM with this capability than LINQ, but compared to the EF framework's query Language LINQ,OQL has its own features, it is closer to SQL, the. NET Framework relies on very little, which makes it possible for you to migrate OQL to Java, C + + Such an object-oriented language.

Here is a simple example of this example, please refer to this blog post, "The dataset is flexible, the entity class is convenient, the efficiency of DTOs: The data container of the sod frame, and the most suitable ORM framework for DDD"

Examples of the entity classes of sod:

 Public classUserentity:entitybase, Iuser { Publicuserentity () {TableName="Users"; Identityname="User ID"; Primarykeys.add ("User ID"); }         Public intUserID {Get{returngetproperty<int> ("User ID"); }            Set{SetProperty ("User ID", value); }        }         Public stringFirstName {Get{returngetproperty<string> ("First Name"); }            Set{SetProperty ("First Name", Value, -); }        }         Public stringLasttname {Get{returngetproperty<string> ("Last Name"); }            Set{SetProperty ("Last Name", Value,Ten); }        }         Public intAge {Get{returngetproperty<int> (" Age"); }            Set{SetProperty (" Age", value); }        }    }

This is a simple user information entity class, it inherits an interface Iuser, after configuring the data connection in app. Config, it can be used as follows:

//Register and create an entity class from the container
Entitybuilder.registertype (typeoftypeof as userentity; //entity classes used as indexers
BOOLFlag = (user["User ID"] ==NULL);//true//Delete test DataLocaldbcontext context =NewLocaldbcontext ();//Automatically create tablesOQL Deleteq =OQL. From (user). Delete (). Where (CMP=>cmp.comparer (user. Userid">",0))//for security, no where condition is not to delete all data    . End;context. USERQUERY.EXECUTEOQL (DELETEQ); Console.WriteLine ("Insert 3 test data");//insert several test dataContext. Add<userentity> (NewUserentity () {FirstName ="Zhang", lasttname="San"}); context. ADD<IUser> (NewUserdto () {FirstName ="Li", Lasttname ="si", age = +}); context. ADD<IUser> (NewUserentity () {FirstName ="Wang", Lasttname ="Wu", age = A });//Find a user surnamed ZhangUserentity UQ =NewUserentity () {FirstName ="Zhang"};OQL Q=OQL. From (UQ). Select (UQ. UserID, UQ. FirstName, UQ. Age). Where (UQ. FirstName). END;//The following statement is equivalent//userentity user2 = Entityquery<userentity>. Queryobject (Q,context. CurrentDatabase);Userentity user2 = context. Userquery.getobject (q);

Note: this instance requires support for the latest version of the SOD framework, and you can use entityquery<t> to manipulate the entity classes in the previous way.

In addition, the ORM for Sod also supports the ability to create entity classes and queries based on interfaces, see the following example:

Static voidtestgoql () {stringsqlinfo=""; //use Itable_user or Table_user below toList<itable_user> userlist =OQL. Fromobject<ITable_User>()                //. Select ()//Select all self-cut. Select (s = =New Object[] {s.uid, s.name, s.sex})//Select only 3 fields. Where (cmp, user) = CMP. Property (user. UID) < -)                . (O,user)=o.asc (user. UID)). Limit (5,1)//limit 5 records per page, take the first page. Print ( outsqlinfo).            ToList ();            Console.WriteLine (Sqlinfo); Console.WriteLine ("User List Item count:{0}", Userlist.count); }

For a detailed description of this feature, see the blog post, "One line of code calls to implement an enhanced ORM framework with field selection + conditional judgment + sorting + paging."

VI. Data Control

The framework supports form programming for Windows Forms,webforms, extending a set of data controls, including commonly used text boxes, check boxes, radio boxes, list boxes, calendar controls, label controls, and so on. These controls all follow the form data interface of the sod, the control that implements this interface will greatly simplify the data operation of the form application, see this blog post for details, please read this article:

"Do not use reflection," "one line of code" for Web, WinForm form data filling, collecting, purging, and crud to the database

You can also download the source code in pwmis.codeplex.com, find the following address corresponding to the Simpleaccesswinform,

or download this pdf.net_v4.6 WinForm data form instance

Or look at this webtesttool.

These 2 sample applications demonstrate how to simplify the programming of CRUD forms using the Data control WinForm.

In addition, if you are WebForms application, open source Project Supermarket management system source code you can see,

or download this directly (version older) Pdf.net_v4.6_opensource (new)

Conclusion:

sod is not only an ORM, it also has sql-map and DataControl, concrete can see the frame official website Http://www.pwmis.com/sqlmap, 9 years of historical achievements, solid and reliable.

Thank you very much for seeing here, I believe you preliminary understanding of the basic functions of the sod frame, if you have other questions, welcome to the project's Open source website pwmis.codeplex.com discussion to post, or to the official blog related articles replies can also.

Finally, I wish all. NET programmers to get rid of the CRUD function Day by day, thank you for the support of pdf.net sod framework as always.

2015 Spring Festival, congratulations to members and other use of the framework of friends beaming, happy, all the best!

Note: If you have not bought the holiday train tickets, recommend this framework development of the author's own development of the "12306 Silent ticket Window Notification Gadget", work Rob ticket 2 not mistaken, green non-toxic security assured!

Dr. Deep Blue.

2015.2 Lunar New Year

Pdf.net SOD Open Source Framework red envelopes delivery Activities && Beginners Quick Start Guide

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.