80O / PlusEMU

39 stars 26 forks source link

Replace QueryReactor with Dapper #12

Open 80O opened 2 years ago

80O commented 2 years ago

The current database query mechanism feels bloated. By using dapper we can simplify querying objects from the database. Dapper is simple enough to replace older queries. https://www.learndapper.com/

Generally there are 5 things required to query the data:

Utilizing dapper we can simplify the last 3 steps:

using var connection = _database.Connection();
var data = await connection.QueryAsync<DataObject>("SELECT id, name, description FROM table WHERE id => @id", new { id = 3});

This is a good first issue to get familiar with parts of the emulator as the queries can be changed one by one. Make sure to test them when you submit your PR!

Note: Do not use async calls without awaiting them. Note: Do not create async voids! Note: Use the non async method call (The one without -Async appended to the method name) in a non async context.

80O commented 2 years ago

This is a continous issue and should be done in small pull requests.

80O commented 1 year ago

Most queries are simple RunQuery calls that can easily be replaced with ExecuteAsync equivalent for dapper. Note: Do not forget to change the parameters from string interpolation to an dynamic object passed.