Is lazy loading possible in dapper? And what is the difference between the generic (POCO) and dynamic API?
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
1: nope; none at all, unless you roll it entirely yourself. It is intentionally minimalistic and deterministic
2: materializing into a POCO is handy if you want to expose that data to other parts of your application, for example as data for a view-model; Query<Customer>
, for example, can populate well-known Customer
objects that you can code against in other places. dynamic
is very convenient, but is not very explorable - and won't work well for data-binding or intellisense. It is, however, really handy for DAL methods that remain very local, or example
var row = conn.Query("select qty, cost from parts where id = @id",
new { id }).Single();
int qty = row.qty;
decimal cost = row.cost;
// and off we go...
or:
var lookup = conn.Query("select id, name from somelookup").ToDictionary(
x => (int)x.id, x => (string)x.name);