First, why discard access?
1. You need to install Access driver on the client's machine
PS: This is more annoying, we all know that the simpler the better, install this is too cumbersome for users.
2. Poor performance during Operation
PS: People who have used access know that this is a time-consuming query when it comes to large amounts of data.
3. No transaction support
Many operations in the actual project need the original transaction support, as for the existence of the business people should understand, access let's not say how bad it is
4. Platform support issues
If we were to deploy our project on Linux, it would be an estimated time to take a break.
Ii. How to discard access with open source stuff
1. Here we recommend the use of SQLite, as to what SQLite is all should be more clear,
In simple terms: like access, a local file database, support transactions, standard SQL, performance in the open source local file database is very good. Support for other operating systems.
2. What is the framework for database operations?
It is recommended to use Moon.orm Standard Edition.
Source code: HTTP://PAN.BAIDU.COM/S/1I3XJ0F7
Third, use the actual example to look at SQLite
1. Use SQLite's management tools. (Recommended Sqliteexpert)
2. Create the following library table
Three sheets: class, student, score
CREATE TABLE [Student] ( [ID] INTEGER not NULL PRIMARY KEY onCONFLICTROLLBACK, [Name] VARCHAR( -) not NULL, [ Age] INT not NULL, [BirthDay] DATETIME not NULL, [Sex]BOOLEAN not NULL, [class_id] INTEGER not NULL REFERENCES [Class]([ID]));CREATE TABLE [Class] ( [ID] INTEGER not NULL PRIMARY KEY onCONFLICTROLLBACK, [ClassName] VARCHAR( -) not NULL, [Classlevel] INT not NULL);CREATE TABLE [score] ( [ID] INTEGER not NULL PRIMARY KEY onCONFLICTROLLBACK, [score] INT not NULL, [student_id] INTEGER not NULL REFERENCES [Student]([ID]));
3. Using the code generator
Latest Version: HTTP://LKO2O.COM/MOON/ARTICLE/9
4. Configure the database connection
5. Generating the Entity layer code
6. Put the generated entity code in your development project
7. Configure your project
8. Start coding
usingSystem;usingMoon_sqlite;usingMoon.orm;usingMoon.Orm.Util;namespacetestsome{classProgram { Public Static voidMain (string[] args) { //Add Data using(vardb=Db.createdefaultdb ()) { //turn on transaction functionalityDb. Transactionenabled=true; /*clears the data table db. Remove<scoreset> (); Db. Remove<studentset> (); Db. Remove<classset> (); */ //Add DataClass cl=NewClass (); All ClassName="class"+DateTime.Now.ToString (); All Classlevel=1; Db. ADD (CL); Console.WriteLine ("add [Class] success, id={0}", cl.id); Student Stu=NewStudent (); Stu. Age= A; Stu. BirthDay=DateTime.Now; Stu. class_id=cl.id; Stu. Name="Zhang San"+DateTime.Now; Stu. Sex=true; Db. ADD (Stu); Console.WriteLine ("add [Student] success, id={0}", stu.id); Score SCO=Newscore (); Sco. Score_=98; Sco. student_id=stu.id; Db. ADD (SCO); Console.WriteLine ("Add [score] success, id={0}", stu.id); //with new dataScore update=Newscore (); Update. Score_= -; Update. Whereexpression=ScoreSet.ID.Equal (sco.id); Db. Update (update); } //Querying Data using(vardb=Db.createdefaultdb ()) { //Connection Query varmqljoin=Scoreset.selectall (). Innerjoin (Studentset.select (Studentset.name)). Innerjoin (Classset.select (ClassSet.ID.AS ("ClassID") , Classset.classname). On (scoreset.student_id. Equal (studentset.id). and (studentset.class_id. Equal (classset.id)); //View current SQL varSql=Mqljoin.todebugsql (); varlist=db. Getdictionarylist (Mqljoin); //Show Datalist. Showinconsole (); //let's not need entity classes stringSql2=Mqljoin.toparameterssql (); Dynamic Dlist=db. Getdynamiclist (SQL2,"Custom class name"); foreach(Dynamic entityinchdlist) {Console.WriteLine (entity.id+" "+entity. Score+" "+entity. Student_id+" "+entity. name+" "+entity. Classid+" "+entity. ClassName); } //Get entity set varEntitylist=db. Getentities<score> (Scoreset.selectall (). Where (ScoreSet.ID.BiggerThan (0))); } console.write ("Press any key to continue ..."); Console.readkey (true); } }}
The project source code download
Address: Http://pan.baidu.com/s/1vyyPg
This project runs open source directly
Let's use open source database and open source framework to discard access