My favorite ORM tool-simple data)

Source: Internet
Author: User

 
Nowadays, many people are using ORM tools. the. NET family usually uses Nhibernate and entity.
Framework. I think EF should be a hardcore Ms fan, and nhib.pdf is an open source supporter.
Apart from both of them, everyone may have their own company's ORM tools. It is not ruled out that some people are still using LINQ to SQL (we just used it for a project we just finished .. Drop ).

I don't like EF's efficiency, but it does integrate seamlessly with SQL Server. nhib.pdf is a good thing, but I always think it is a bit complicated. So I recommend simple data for you.

I have previously written a small system, such as Asp.net MVC + MongoDB + autofac, to build a lightweight Blog system. (1) I use the simple data ORM tool. It is mainly based on dynamic features of. NET Framework 4.0.

This articleArticleWe will introduce the addition, deletion, modification, and query of simple data and the SQL generation script corresponding to the transaction. You will find that the script generated by simple data is really a simple SQL statement. Therefore, the efficiency is quite good. And, just like its simple name, it is quite simple to use.

Preparations:

This class works with the data operation factory in nhib.pdf or EF.

Add record:

Let's take a look at the method implemented by using the dynamic feature when adding a record.

 

Insert data directly using attributes and corresponding values. You do not need to instantiate a user class and assign values to the attributes. Of course, simple data also supports direct operations on an object.

Other types of inserts are also supported, such:

 
Dynamic user = new expandoobject ();

Corresponding generated SQL script:

 

 

Modify record:

 

This also uses the dynamic feature to modify data ..... You can also use static entities to update corresponding records.

 

Corresponding generated SQL script:

 

Delete record:

The most basic deletion method is that we can delete corresponding records by ID.

Corresponding SQL statement:

Query records:

A query can return a single record, or a dynamic entity or ienumerable set..

Corresponding SQL statement:

 

For more examples and usage, go to the official website to download them.CodeResearch. This ORM tool is really good.

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.