Unity3d free and easy to use database processing Framework Database Direct connection Framework

Source: Internet
Author: User
Tags generator sqlite database

I. Overview

Not long ago there was a buddy doing PC game development. Use to Unity3d,

Just found me.

I offered him a way to unity3d how to Moon.orm to intelligently program.

Let's take a look at how to make sqlite more convenient.

Http://www.cnblogs.com/humble/p/4593133.html

usingSystem;usingMoon_sqlite;usingMoon.orm;usingMoon.Orm.Util;namespacetestsome{classProgram { Public Static voidMain (string[] args) {            //Add Data            using(Var db=new sqlite ("SQLite's link string")) {                /*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 (); DynamicDlist=db. Getdynamiclist (SQL2,"Custom class name"); foreach(DynamicEntityinchdlist) {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); }    }}

Second, how to use in Unity3d.

1. Download Moon.orm

:

Http://lko2o.com/moon/article/3

2. Quoting Moon.orm.dll

3. Place the library to the following location

Put Moon.orm.dll, System.Data.SQLite.dll, SQLite.Interop.dll SQLite database files into the Unity3d editor EXE location;

The query results can be seen directly in the editor.

Note: As well as in the final target program there is also a copy. (after build and then put)

4. Using the code generator

This link describes how to use the code generator: http://www.cnblogs.com/humble/p/4593133.html

5. Start coding

using (var db=New SQLite ("SQLite's link string ")) {  var mql= Userset.select (Userset.name). Where (UserSet.ID.Equal (9));   var name=Db. Getscale (MQL). ToString ();}

Unity3d free and easy to use database processing Framework Database Direct connection Framework

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.