3

Does anyone know or have link in how to use https://github.com/henkmollema/Dapper-FluentMap in my Dapper CRUD?. Right now I am using Dapper.Contrib but we are trying to implement Clean architecture which we remove the Dapper.Contrib in our structure. Now I am trying to use this Dapper-FluentMap to map the properties but there documentation is very poor.

user3928241
  • 135
  • 2
  • 10

2 Answers2

6

I've wrote an article and a sample that shows how to use Dapper-FluentMap:

https://medium.com/dapper-net/custom-columns-mapping-1cd45dfd51d6

mauridb
  • 1,467
  • 9
  • 12
  • Is there any way we can Register the Fluent Mapper only once instead of adding the newly created Map every time in the registry. Something like Register all classes ending with "Map" – Akshay G Sep 22 '18 at 10:51
  • There is not native support for registering all classes automatically, but you can do it using a bit of Reflection, looking for all classes derived from EntityMap and then instantiate it using Activator.CreateInstance – mauridb Sep 23 '18 at 16:59
  • it's a nice article and all, but how does one use nested objects, like the Company class in your User class, you never gave an example of that in your article, why did you stop short only binding the id column in the example? – inifus Apr 12 '21 at 22:37
  • @inifus 'cause I think the best solution is to use Custom Type Handling. See the last two article here: https://medium.com/dapper-net/dapper-net-tutorial-summary-79125c8ecdb2. In the GitHub sample, anyway, you have the full mapping sample with the three classes. In the article I favored brevity and clarity and I left the full implementation details for the GitHub repo :) – mauridb Apr 15 '21 at 04:05
2

After beating my head against a few brick walls, I have established this much as fact (at least as of late 2018, which is after the date of the OP)...

Answering the question "Is FluentMap supposed to work with Dapper.Contrib extensions?", henkmollema (author of Dapper.FluentMap) responds, "Nope, it does not work with Dapper.Contrib".

So there's your answer, user3928241.

However for me as well as for user3928241 and others desperately searching for answers, he adds, "Shameless plug: it does work together with Dommel using the Dapper.FluentMap.Dommel integration component."

YMMV, but I'm pressing on. Going to try Dommel now.

Wellspring
  • 1,128
  • 1
  • 10
  • 19