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.