In my opinion of. NET development, or to implement the minimalist optimization method. Knock out type convert with my simplified ORM implementation principles and implementation details, the most simplified development method

Source: Internet
Author: User

Now, the. NET or framework, we agree with a variety of large and small, ef,subsonic,nhibernate, and even small petapoco this, but used the people I think they consider is more.

The smaller Petapoco also have thousands of lines of code.

Some of them are difficult to configure, or they can't get out of SQL,

And I've been looking for a simpler way to streamline my development and make it easier to manipulate data.

Due to the recent use of MySQL, while MySQL uses the Myism engine and the InnoDB engine, because the InnoDB engine supports a broader, transactional, and so on, although the character index may be less myism, but the use is necessary.

I started to write a small or type.

The concrete realization idea is Knock out converter.

In the previous article, I personally think that the idea of software OO is to minimize the input configuration and optimize the simplification and reconstruction of OO methods.

We all know that in the development, the received data is often a string type, if using webservice,wcf,remoting and other remote interface, the method is directly the entity, but in collaboration with the database often need to be the model type in parameter Specifies the type of database that the. NET Framework actually has is a infertype, that is, when manipulating data, not specifying a database type, just adding prametername and value, you can manipulate the library directly, The validation of data types in the context of the library's operations also eliminates the hassle of typing on the program, which is, of course, a trickery approach, but is the simplest and easiest to manipulate.

This is also the core part of the or tool I wrote myself.

Thought is still "convention greater than configuration", assuming that the table default contains the ID primary key, auto-growth, the single table name and the entity name lowercase relative, then we can construct the corresponding library table operation statement according to these conventions.

For SQL injection, we all know that parameter is often re-coding parameters to some extent anti-injection, so we can also construct the corresponding SqlParameter, through the factory and abstract SqlHelper, The concrete sqlhelper is injected into the operation class to implement the unified operation of the various libraries. This makes it possible to implement a single-table ORM.

For the character length and so on can be implemented according to Ef,subsonic, add attributes, limit the character length, set the primary key column, if there is no keycolumn, the default convention with the ID column

I personally think that if you add a character length to the entity, the data type and validation of regular expression, you can generate direct SQL directly from the entity, then you can implement code first, but DB first is often the way we use it more, so, The extension can be so realized, and the principle is this, ORM is the basic idea.

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.