Dapper cant run #678
Replies: 1 comment
-
See #679 There were some bugs in DapperRepository and the sql that's executed in GetProductViaDapperRequest. But next to that, the entities we have now (Product and Brand) are designed to be used with Entity Framework. Trying to use those same entities with Dapper opens a whole can of worms apparently. I added a default constructor to the Product entity to enable this scenario which kind of breaks the "encapsulation". Another option would be to add a tenantId argument to the existing constructor, but can't really do anything with that, as the TenantId is a shadow property now. It would only be there to satisfy the dapper requirement. Also using mapster threw a nullreference exception (due to the "BrandName" property in ProductDto and the product not having a Brand assigned), so I changed it to a manual mapping now. Reflecting on this... I don't think the way we are using dapper here is how it should be used. We have the SQL query in the Application project, which makes it dependent on the database, which is not right. Also the fact we're trying to showcase both entity framework and dapper on the same example entities is making things more confusing I think. We should build another example to showcase dapper or use it for something which is not already implemented by using entity framework. |
Beta Was this translation helpful? Give feedback.
-
how to fix this
im begginer for using Dapper
Code Like This
if im remove
AND \"TenantId\" = '@tenant'
Error like this
Beta Was this translation helpful? Give feedback.
All reactions