SQLite for. net

Source: Internet
Author: User

The database seems to be less used by game clients in China. I see that it is converted by myself using Excel...

In fact, I always wanted to add a database to the engine, but this is closely related to the game logic, so I didn't do it...

However, it can be determined that the best choice for a database that runs out of the server should be SQLite.

I used it when using. NET as a tool. So I checked and found two solutions:

  • SQLite-Net

    • Small, a CS file, and a native DLL (C ++ can also be called)
    • The interface is clear and easy to understand.
    • Supports LINQ. Although small, it has many functions.
    • It is equivalent to a packaging of native SQLite c api.
  • System. Data. SQLite
    • Access through ADO. net
    • It can be integrated with vs designer, saving a data editor
    • For those who have used ADO. net, they will soon be able to get started.
    • If you use another database (such as MySQL) Later, you do not need to change the code.

Create a WPF Data Binding demo for the northwind database:

<Dockpanel> <br/> <ListBox name = "listcategory" itemssource = "{binding}" minwidth = "100" selectedindex = "0"> <br/> <ListBox. itemtemplate> <br/> <datatemplate> <br/> <textblock text = "{binding categoryname}"> </textblock> <br/> </datatemplate> <br/> </ListBox. itemtemplate> <br/> </ListBox> <br/> <stackpanel> <br/> <textbox text = "{binding selecteditem. categoryname, elementname = listcategory} "> </textbox> <br/> <textbox text =" {binding selecteditem. description, elementname = listcategory} "> </textbox> <br/> <Image Source =" {binding selecteditem. picture, elementname = listcategory} "> </image> <br/> </stackpanel> <br/> </dockpanel> <br/>

If you are pursuing powerful functions and automation, you can select the latter.

The former requires you to define the class corresponding to the table, which is not so convenient, but the code is much simpler:

VaR DB = new sqliteconnection ("database/northwind. db3 "); <br/> var result = dB. query <Category> ("select * from categories"); <br/> This. datacontext = result; <br/> 

For those who have never been familiar with ADO. net, this direct operation method is better understood.

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.