Install SQLite in. 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:

XHTML code
  1. <Dockpanel>
  2. <ListBox name = "listcategory" itemssource = "{binding}" minwidth = "100" selectedindex = "0">
  3. <ListBox. itemtemplate>
  4. <Datatemplate>
  5. <Textblock text = "{binding categoryname}"> </textblock>
  6. </Datatemplate>
  7. </ListBox. itemtemplate>
  8. </ListBox>
  9. <Stackpanel>
  10. <Textbox text = "{binding selecteditem. categoryname, elementname = listcategory}"> </textbox>
  11. <Textbox text = "{binding selecteditem. Description, elementname = listcategory}"> </textbox>
  12. <Image Source = "{binding selecteditem. Picture, elementname = listcategory}"> </image>
  13. </Stackpanel>
  14. </Dockpanel>

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:

C-sharp code
  1. VaR DB = new sqliteconnection ("database/northwind. db3 ");
  2. VaR result = dB. query <Category> ("select * from categories ");
  3. This. datacontext = result;

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.