PHPFixing
  • Privacy Policy
  • TOS
  • Ask Question
  • Contact Us
  • Home
  • PHP
  • Programming
  • SQL Injection
  • Web3.0

Sunday, July 3, 2022

[FIXED] what database does windows applications work with that runs with the start of the app?

 July 03, 2022     .net, database, mysql, windows, xampp     No comments   

Issue

so here's the deal , it's my first time developing a windows app for a client , who obviously can't run xampp each time to get the MySQL database running to use the app (cause the app needs to fetch data from the db) , so my question is how do i make a normal windows app whose db starts after starting the app itself? how do most people do it? what db do they use? preferably a free solution


Solution

There's a lot of different choices. One commenter mentioned SQLite and SQL Server Compact edition, but if you're running the database locally you should consider if you need something that complex or if it is just overkill.

You may want to consider LINQ or LINQ to XML. LINQ is a query API built into C# .NET, incredibly performant in newer versions of .NET such as Core 3.1, and very cleanly integrated with the C# ecosystem as a whole.

Using bare LINQ, you can load your data on startup from any sort of file format (XML or JSON are popular, I've recently started using FlatBuffers, a standard developed by Google) where you have a List<YourObjectModel> containing all your database entries. YourObjectModel here would be a class representing a database row. From there, you can structure queries in one of two ways. There's the SQL style

List<YourObjectModel> dataBase = LoadData();
var result = from entry in database
             where entry.FieldA == "something"
             select entry;

Or, my preference, the fluent style

var result = database.Where(entry => entry.FieldA == "something");

In practice, you can do anything with LINQ that you could do with SQL, including sorting, pivoting, grouping, etc. LINQ has a lot of benefits, but my favorite selling point is "lazy evaluation", where LINQ doesn't execute your whole query at one time if it can avoid it. If you don't sort, convert the IEnumerable<T> to a different container, or read the Count property of the result, LINQ will run the query just long enough to get one result and then have it ready. This can result in a big performance boost if you pass the results into a foreach loop or some other scenarios.

A bit of anecdotal evidence, I was working on a simple 2D game engine and I needed to sort entities by their Z coordinate so I could draw them from back to front. I was lazy and used a LINQ query to sort a List<GameEntity> containing over 10,000 objects because it was a one-line solution. It ran great. I went back and implemented a proper sort and found it was actually slower than LINQ. I spent an afternoon trying to implement a sorting algorithm faster than LINQ's and couldn't.



Answered By - Steven Gann
Answer Checked By - Marie Seifert (PHPFixing Admin)
  • Share This:  
  •  Facebook
  •  Twitter
  •  Stumble
  •  Digg
Newer Post Older Post Home

0 Comments:

Post a Comment

Note: Only a member of this blog may post a comment.

Total Pageviews

1,206,274

Featured Post

Why Learn PHP Programming

Why Learn PHP Programming A widely-used open source scripting language PHP is one of the most popular programming languages in the world. It...

Subscribe To

Posts
Atom
Posts
Comments
Atom
Comments

Copyright © 2025 PHPFixing