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.