OOP Application: entity class, oop Application entity

Source: Internet
Author: User

OOP Application: entity class, oop Application entity
Entity class

Definition: An entity class is a business entity class, and a business entity is the object involved in the business of the entire software system.

Usage:

1. Add an object class project, add a class library project, and use. Modes as the suffix.

2. Extract objects and attributes. (Simply put, an object is a table, and an attribute is a column in each table .)

3. Add references to entity-class projects at the data access layer and presentation layer.

Tip: it is best to use static (static) for common methods ).

 

App. config (configuration file)

Definition: App. config is an XML file that stores the database connection string.

Usage:

1. Add the application configuration file in the presentation layer.

2. Edit the configuration file. Syntax:

          

<?xml version="1.0" encoding="utf-8" ?><configuration>    <connectionStrings>      <add name ="ClassRoomConnectionString"           connectionString="Data Source=.;Initial Catalog=Name;User ID=sa;Password=sa"           providerName="System.Data.SqlClient"/>    </connectionStrings>    <startup>         <supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.5" />    </startup></configuration>

3. Add reference (System. Configuration) to the project that needs to call the Configuration file)

4. Reference The namespace (using System. Configuration) in the class that needs to call the Configuration file)

5. Use the connection string. Syntax:

private static readonly string conn = ConfigurationManager.ConnectionStrings["ClassRoomConnectionString"].ToString();

 

Const and Readonly

Similarities and Differences:

1. const can modify fields and local variables in the class. readonly can only modify fields of the class.

2. For constants of the reference type, the possible values of const can only be string and null.

3. the const modifier constant must be assigned a value during the Declaration. readonly can assign a value when running the program.

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.