Teach you how to write an ORM (1)

Source: Internet
Author: User
This is the first article in the hands-on series. I hope the experts can leave. Please continue.

Here we will analyze the design and implementation process of a semi-automatic ORM similar to ibaties step by step for cainiao's reference. The function is very simple, and I can only describe it in a simple way, however, after breaking down some key points, I hope that the back waves will not have to spend any more time exploring them.

Why do we need to reinvent the wheel? It is impossible to invent a firewheel without having to invent the wheel myself.

Prerequisites:
C # should be used first. If not, please go to the bookstore to buy books first.
To be familiar with ADO. net, we will not re-design oledb, so all operations will be completed by ADO. net.
At least we know what XML is. Our configuration file depends on this thing.
It is best to reflect that, if you find that there is no such thing, you can search for it on Google. Google is the best teacher, except to teach me to writeProgramIt also taught me how to make a cool chicken wings sister, God bless Google.

When everything is ready, do not forget to install vs2005 on your machine. In line with the principle of keeping pace with the times, we still give up version 1.1. After all, the model can makeCodeMore concise.

Open your vs2005, create a project, right-click the properties of the project, and write your name in the namespace. Now, you are about to officially start to complete your own ORM framework. If you refer to this article, congratulations, this year's best cainiao is not yours. I would like to reiterate that in the eyes of experts, this is a very weak and repetitive invention wheel. If you have invented it, don't read it and waste time.

Well, don't be too excited when the project is built. Now we are planning and planning. As the saying goes, it is the king to sharpen the knife and not cut firewood by mistake.

first of all, we need to determine the scope of this project. Don't swear at the very beginning that we want to be the best in the world, we just implemented a demo. So a lot of flashy things need to be removed. We use ibaties as the blueprint, so we need to provide a configuration file for each class, in addition, the Service is automatically loaded when the configuration file is modified, instead of restarting the service. Here we think the ibaties configuration file is too complicated, so we can simplify it again. We only configure sqlmap, but the object ing is configured in the object class through attribute, and the resultmap is also saved, how to come. The cache mechanism should be retained. After all, it should be demonstrated that lazyloading is enough. We need AOP. We will ignore it for the moment and load the code once we call it. I will definitely use it better than lazyloading, too lazy is not necessarily simple.
OK, that's simple. We don't want to summarize the requirements for the moment. As a trainee architecture designer, we need to practice more to grasp the requirements. This is the right to use it as a task. If you are interested, you can write it. We will continue to design it tomorrow.

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.