Simple graduation design with asp.net MVC3

Source: Internet
Author: User

A friend wants to make a graduation project and ask me to help him develop a simple library management system. I have nothing to do at night, so I am ready to help him develop a simple one. Because it is a graduation project, I plan to use a technology that is rarely used in my work to develop it. I also want to train myself. So I chose Entityframework, spring.net, asp.net MVC and other technologies for development. The following is the project structure of my project:

 

Common is a public class that stores public classes that are not related to the business, and also contains extension methods in this class library.

Domain is the Domain logic layer, which stores Domain objects.

DTO is the data transmission Object layer, which is mainly used to transmit data objects. In MVC, the data transmission objects from Controller to View or View to Controller are also placed here, And ViewData is not used.

The Filter layer is used to control permissions and operation log records.

Model is a Model level, Entityframework object, and some enumeration objects are placed in this layer.

Repository is the database persistence layer.

 

EntityFrameworkHeper code:

 

1 using System;
2 using System. Collections. Generic;
3 using System. Linq;
4 using System. Text;
5 using Com. Romi. YangXiaoDong. Model;
6 using Com. Romi. YangXiaoDong. IRepository;
7 using System. Threading;
8
9 namespace Com. Romi. YangXiaoDong. Repository
10 {
11 /// <summary>
12 // persistence base class
13 /// </summary>
14 public class BaseRepository
15 {
16 private static ThreadLocal <BookManageEntities> threadLocal = new ThreadLocal <BookManageEntities> ();
17 # region IBaseQuery Member
18 /// <summary>
19 // open
20 /// </summary>
21 /// <returns> </returns>
22 public BookManageEntities GetSession ()
23 {
24 BookManageEntities session = (BookManageEntities) threadLocal. Value;
25 if (session = null)
26 {
27 session = new BookManageEntities ();
28 threadLocal. Value = session;
29}
30 return session;
31}
32 /// <summary>
33 // close
34 /// </summary>
35 public void CloseSession ()
36 {
37 BookManageEntities session = (BookManageEntities) threadLocal. Value;
38 if (session! = Null)
39 {
40 session. Dispose ();
41}
42}
43 # endregion
44}
45}

 

The above code is modeled after the help class of Hibernate in java. If you have any questions, I would be very grateful to you.

This article mainly introduces the basic structure of the trainer project. The next article will briefly introduce the simple application of EntityFramework in this project.

It is the source code, but it simply implements the user management function.

/Files/kimiyang/BookManage.rar

/Files/kimiyang/Com.Romi.YangXiaoDong.Model.rar

 

Related Article

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.