✅ Not able to Insert data to table using Dapper

Hey folks! I'm trying to have Dapper insert a MapsModel to the database with a relation to the PlayerModel. However, when I try to do that, I get this error:
A fatal error occured while trying to handle chat command: The member Player of type EvoSC.Common.Database.Models.Player.DbPlayer cannot be used as a parameter value
A fatal error occured while trying to handle chat command: The member Player of type EvoSC.Common.Database.Models.Player.DbPlayer cannot be used as a parameter value
The code I use can be found in this pastebin: https://pastebin.com/q99mmvnX Anyone know how I can solve this?
Pastebin
[Table("Maps")]public class DbMap{ [Key] public long Id { get...
Pastebin.com is the number one paste tool since 2002. Pastebin is a website where you can store text online for a set period of time.
4 Replies
Angius
Angius3y ago
Dapper is a very light ORM It just does some basic mappings It won't insert nested data, like that DbPlayer nested inside of DbMap You'd need to insert the player first, get the generated ID, then insert the map Or write SQL that does both manually Or... use EF that will be able to insert nested data no problem
AtomicLiquid
AtomicLiquidOP3y ago
Alright, great to know. We're using Dapper because its quite a bit faster than EF, just have to get used to it. Thanks alot for the response!
Angius
Angius3y ago
Eh, it's not that much faster In face, EF Core is on par with a lot of the time
Accord
Accord3y ago
Was this issue resolved? If so, run /close - otherwise I will mark this as stale and this post will be archived until there is new activity. Closed!

Did you find this page helpful?