MVC series (repository mode, LINQ, EF, IOC framework Castle, jquery, Ajax) (2) models (ORM)
MVC series (repository mode, LINQ, EF, IOC framework Castle, jquery, Ajax) (3) models (ORM, repository mode, paging)
I haven't updated it for a long time. I 've been mixing it all day in my blog. I don't have any of my own things, so I am always a little confused. In fact, I have the idea of writing something every day, but it is delayed for various reasons (in fact, laziness. Today, I finally have to think about it. It is really a matter of course to write something that I learned in my project. It is a matter of knowledge management. Of course, if you can help your work or study, I am very pleased. Because the younger brother was a beginner, he was suspected of having a shift in the garden of crouching tigers, dragons, and dragons.
due to the confidentiality of the company's projects, I can write a small software for online accounting, it involves the repository mode, LINQ, EF, IOC framework Castle, jquery, Ajax and other technologies used in my project. I'm a beginner, and I'm sure there are a lot of failures. Thank you for your criticism.
these examples are called the broken children's network ledger.
function:
1. the user logs on to the system and displays the latest accounting list
2. you can keep your account at any time (time, Account type, income or expenditure, amount, location, content, etc.)
3. smart Search
4. statistics
5. ability to excel tables everywhere
the function is relatively simple. You can directly design the database without drawing the example diagram.
now we directly perform database modeling. The modeling tool is ea,
database model diagram:
Users: User table
Accounts: account limit
Accountstypes: Account type table (clothing, food, shelter, etc)
Next, create a database:
The database uses SQL Server 2000.
Database Name: pbaccount
SQL statement:
Create Table [ Accounts ] (
[ Accountid ] [ Uniqueidentifier ] Not Null ,
[ Userid ] [ Uniqueidentifier ] Not Null ,
[ Inorout ] [ Bit ] Not Null ,
[ Amount ] [ Float ] Not Null ,
[ Typeid ] [ Uniqueidentifier ] Not Null ,
[ Time ] [ Datetime ] Not Null ,
[ Status ] [ Int ] Not Null ,
[ Detail ] [ Image ] Null ,
Constraint [ Pk_accounts ] Primary Key Clustered
(
[ Accountid ]
) On [ Primary ] ,
Constraint [ Fk_accounts_accounttypes ] Foreign Key
(
[ Typeid ]
) References [ Accounttypes ] (
[ Accounttypeid ]
),
Constraint [ Fk_accounts_users ] Foreign Key
(
[ Userid ]
) References [ Users ] (
[ Userid ]
)
) On [ Primary ] Textimage_on [ Primary ]
Go
Create Table [ Accounttypes ] (
[ Accounttypeid ] [ Uniqueidentifier ] Not Null ,
[ Accounttypename ] [ Char ] ( 20 ) Collate chinese_prc_ci_as Not Null ,
Constraint [ Pk_accounttypes ] Primary Key Clustered
(
[ Accounttypeid ]
) On [ Primary ]
) On [ Primary ]
Go
Create Table [ Users ] (
[ Userid ] [ Uniqueidentifier ] Not Null ,
[ Loginname ] [ Char ] ( 20 ) Collate chinese_prc_ci_as Null ,
[ Name ] [ Char ] ( 10 ) Collate chinese_prc_ci_as Null ,
[ Sex ] [ Bit ] Null ,
[ Birthday ] [ Datetime ] Null ,
[ Sion ] [ Char ] ( 10 ) Collate chinese_prc_ci_as Null ,
[ Role ] [ Int ] Null ,
Constraint [ Pk_users ] Primary Key Clustered
(
[ Userid ]
) On [ Primary ]
) On [ Primary ]
Go
Note: Only when the relationship between tables needs to be set can the correct ORM be automatically generated, for example:
OK. The database design has been completed. Next we will discuss the application of the EF, LINQ, and resposity modes.
Note: Install vs2008 SP1, ASP. NET mvc1.0:Http://www.microsoft.com/downloads/details.aspx? Familyid = 53289097-73ce-43bf-b6a6-35e00103cb4b & displaylang = en