How to dynamically generate SQL statements based on entities

Source: Internet
Author: User

Background:

In the process of project development, it is often necessary to modify the SQL statement according to the value of the entity, for example, there is a student class Stu, the code is as follows:

1      Public classStudent2     {3          Public intID {Get;Set; }4          Public stringName {Get;Set; }5          Public intGrade {Get;Set; }6          Public stringNick {Get;Set; }7          Public stringCity {Get;Set; }8}
View Code

Add a student record to the data table, sometimes, can only get some student information, such as: Do not know the student SHARPL grade information, the code is as follows:

1             New Student (); 2             "  Sharp " ; 3             " Beijing ";

The Grade field value will take the default value of C # shaping data, then Stu. Grade is actually equal to 0, the information added to the database is not ideal, and the grade should be null when the student grade attribute value is unclear.

  

How to dynamically generate SQL statements based on entities

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.