C#
C#

help

Root Question Message

AtomicLiquid
AtomicLiquid11/19/2022
✅ 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

The code I use can be found in this pastebin:
https://pastebin.com/q99mmvnX

Anyone know how I can solve this?
Angius
Angius11/19/2022
Dapper is a very light ORM
Angius
Angius11/19/2022
It just does some basic mappings
Angius
Angius11/19/2022
It won't insert nested data, like that DbPlayer nested inside of DbMap
Angius
Angius11/19/2022
You'd need to insert the player first, get the generated ID, then insert the map
Angius
Angius11/19/2022
Or write SQL that does both manually
Angius
Angius11/19/2022
Or... use EF that will be able to insert nested data no problem
AtomicLiquid
AtomicLiquid11/20/2022
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
Angius11/20/2022
Eh, it's not that much faster
Angius
Angius11/20/2022
In face, EF Core is on par with a lot of the time
ContactFrequently Asked QuestionsJoin The DiscordBugs & Feature RequestsTerms & Privacy