Extensions of Dapper (or generally any ORM) support auto-query-generation. To do it, they need to know the table name against which the query should be generated. They know it by looking at generic type of entity passed in and relating it with mapping done.
You are attempting to insert an object
type. There is no way for ORM to know for which table the query should be generated. That is why, what you are attempting to do is not possible.
This does not work despite having PersonEntity
mappings registered with the OrmConfiguration
Again, there is no way for ORM to know that your object
is PersonEntity
. You have mapped PersonEntity
and passing in an object
.
To make it happen, cast an object
with exact entity:
connnection.Insert(person as PersonEntity);
While Insert
, your code know what you are inserting. Simply casting to specific type should resolve the issue.
As mentioned in the document, you can use SQL Builder feature of tool. I never used the toolkit so I do not know if this will help you; just suggesting looking at documentation.
A useful SQL builder and statement formatter which can be used even if you don't need the CRUD features of this library.
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…