Replace QueryReactor with Dapper
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:
- DbClient
- Executing the statement
- Looping over each result
- Creating a new instance
- Converting the parameters to the right type
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.
This is a continous issue and should be done in small pull requests.
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.