Im trying to make a generic method for Dapper.Query. Now i have run into trouble.
Here is my example
public IEnumerable<T1> Lazy<T1, T2>(T2 table) where T1 : EntityBase
{
using (IDbConnection cn = GetCn())
{
cn.Open();
return cn.Query<T1, T2, T1>("query", (t1, t2) => { t1.???
}
}
As you se below, i need to now the properties in t1 to load it with t2.
Is this even possible?
This example is not completed, of course the “query” string will be replaced, this is just for demo.
Dapper does not include lazy loading, and provides exactly zero support to help achieve lazy loading, because that isn’t what it is trying to do – it is a utility, not a framework. However, your example suggests you are talking about horizontally partitioned data, for example, say we had:
and suppose for simplicity that both
[foo]and[bar]have anIdcolumn (which it handles automatically, although there are ways of specifying the partitioning rules manually). Then this would become:or something similar. The point is: it materializes the
Fooand theBarseparately (based on the partition), then lets you worry about how to combine them.