Search code examples
c#dapper

Is lazy loading possible in dapper? And what is the difference between the generic (POCO) and dynamic API?


I have two question about working with dapper:

  1. Is there any way to load navigation key property like entity-framework (lazy-loading)?

  2. What's difference between POCO serialization and dynamic serialization? which is better? and how can I use this serialization?


Solution

  • is there any way to load navigation key property like entity-framework (lazy-loading)?

    No, Dapper is a direct-SQL library, and that's why it's so ridiculously fast. There is no overhead surrounding automated loading. You can however load more than one entity at once.

    what's difference between POCO serialization and dynamic serialization? which is better? and how can i use this serialization?

    POCO serialization is more efficient because the type is well known at compile time, dynamic serialization is a bit more expensive because it has to be evaluated at run-time. Other than that there isn't really a difference.

    However, I would recommend Dapper above all other libraries anywhere. It's simple, fast, and extremely flexible. And believe me, I've used a lot of frameworks and libraries for data access.

    Dapper Documentation

    Have a look at Multi Mapping and Multiple Results