The volleyball competition scoring program of MVC--(iii) design and implementation of model class

Source: Internet
Author: User

An entity class is a representation of a real entity in a computer. It runs through the entire architecture and is responsible for transferring data between all levels and modules. In general, entity classes can be classified as "anemic entity classes" and "hyperemia entity Classes ", which only preserve the attributes of entities, while the latter also contain relationships and logic between some entities.

In most cases, the entity class and the table in the database (this refers to the entity table, does not include a many-to-many correspondence of the relational table) is one by one corresponding, but this is not a limitation, in the complex database design, there may be an entity class corresponding to multiple tables, or cross-corresponding situation. In the demo of this article , the entity class and table are one by one corresponding, and the attributes in the entity class and the fields in the table correspond.

Look at the engineering structure of the system before looking at the code of the entity class.

Engineering structure diagram

As shown in the initial phase, the entire system consists of 6 projects, and their responsibilities are as follows:

view--view, rendering data

model--Storing entity classes
controller--controller, handling user requests
This is only an initial structure, mainly to the whole system to build a framework, in the follow-up development, there will be other projects are added on a continuous rolling.

Our entity class will be placed in model, here are three classes of files: Team.cs, Ju.cs,score.cs, respectively, is the team class, the fractional class and the second class. The specific code is as follows:
Publicclassteam

{

[Key]

Publicinttid {get; set;}

[Display (name = "team Name")]

publicstringtname {get; set;}

[Display (Name = "result")]

Publicstringtresult {get; set;}

Publicinttparentid {get; set;}

}

Publicclassju

{

[Key]

Publicintjid {get; set;}

[Display (Name = "innings")]

Publicstringjuci {get; set;}

[Display (Name = "score")]

Publicstringjscore {get; set;}

Publicinttjid {get; set;}

}

Publicclassscore

{

[Key]

Publicintsid {get; set;}

[Display (Name = "score")]

Publicintascore {get; set;}

[Display (Name = "score")]

Publicintbscore {get; set;}

[Display (Name = "Remarks")]

publicstringnote {get; set;}

Publicintsjid {get; set;}

}

Publicclasscountscoredbcontext:dbcontext

{

Publicdbset<team>team {get; set;}

Publicdbset<ju> ju{get; set;}

Publicdbset<score>score {get; set;}

}

As you can see, the code for the entity class is simple, just the representation of the entity and the delivery of the data, with no logical content.

The volleyball competition scoring program of MVC--(iii) design and implementation of model class

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.