I am currently using .NET6 and this sqlite https://github.com/praeclarum/sqlite-net for a small project. I wanted to know what the best way to get a good ORM going. I used to use Dapper in the past for System.Data.Sqlite but that has issues of its own.
Say we have an example schema (primary key, auto increment , db layout are irrelevant so dw about it, just using this for an example and not in the real world)
public class House{ public int Id {get;set;} public string Name {get;set;}}public class HouseCost{ public int Id {get;set;} public int HouseId {get;set;} public decimal Cost {get;set;}}public class HouseDto{ public House house {get;set;} public HouseCost {get;set;}}
public class House{ public int Id {get;set;} public string Name {get;set;}}public class HouseCost{ public int Id {get;set;} public int HouseId {get;set;} public decimal Cost {get;set;}}public class HouseDto{ public House house {get;set;} public HouseCost {get;set;}}
How can I bind this inner join into HouseDto?
SELECT * FROM House INNER JOIN HouseCost ON HouseCost.HouseId = House.Id
SELECT * FROM House INNER JOIN HouseCost ON HouseCost.HouseId = House.Id
Now, I know I can just make a class and paste them in such as
public class HouseDto{ public int Id {get;set;} public int HouseId {get;set;} public decimal Cost {get;set;} public string Name {get;set;}}
public class HouseDto{ public int Id {get;set;} public int HouseId {get;set;} public decimal Cost {get;set;} public string Name {get;set;}}
But there are 2 issues with this approach.
Issue #1. It gets messy, like real messy if I want to add/change some things. Issue #2. How would it know where to Bind HouseId and HouseCost's Id, since they are both the same name. I'd assume I'd need to have an attribute to make them unique? With dapper, this was solved by letting it bind to each individual object, which would prevent all these issues. But I cannot seem to figure out how it's done in sqlite-net.
I know it may not be possible with this library. If it isn't possible, is there a library similar to this that supports Async reading/writing with full multi-threading with the basic