Infrastructure for backend in C# .Net - Dynamic mapping using reflection, low code ORM, etc.
// Declare a QueryGenericHandler<T> Object
var usr = new User(); // In this example we can use User class
var query = new QueryGenericHandler<User>(usr);
// Set wheres and other filters
query.Where(u => u.Username == "UserTest" && u.IsActive);
// Then execute the query
var result = await query.RunQuery()?[0]; // Get the first result
The QueryGenericHandler object build a query use the name of the class and its fields to build a query, assuming a table or view exists that matches the class and its fields and will automatically be mapped at runtime.
// User model example
User usr = new User
{
Username = "UserFromApi",
Email = "userfromApi@yahoo.cool",
Name = "Big",
LastName = "Mom",
Profession = "dev",
IsActive = true,
IsBlocked = false,
};
var cmd = new CommandGenericHandler<User>(usr);
// Insert to the User table
await cmd.RunInsert(usr);
// On startup.cs
SQLConnection.SetConnectionString("Server=localhost;Database=DalionDev;Integrated Security=SSPI");
MIT
Free Software, Hell Yeah!