Note that there are some explanatory texts on larger screens.

plurals
  1. POPaged, Multi-Poco queries with Petapoco?
    text
    copied!<p>PetaPoco is great and covers <a href="http://www.toptensoftware.com/Articles/74/PetaPoco-Paged-Queries" rel="nofollow">paged queries</a> and <a href="http://www.toptensoftware.com/Articles/115/PetaPoco-Mapping-One-to-Many-and-Many-to-One-Relationships" rel="nofollow">Multi-Poco mapping</a>, but I'm trying to figure out if there's a way to do them together? </p> <p><strong>Edit:</strong> </p> <p>Here's the repository method I use to get MultiPoco data:</p> <pre><code>// variables, used in multiple repo methods private readonly string _selectClause = String.Format(@"SELECT * FROM Clients OUTER APPLY (SELECT TOP 1* From Events WHERE Events.EndDateTime &gt;= '{0}' AND Events.ClientId = Clients.Id ) Events WHERE Clients.TenantId=@0", DateTime.UtcNow); private readonly string _orderbyClause = "ORDER BY Clients.Lastname"; // method public new IEnumerable&lt;Client&gt; AllByTenantAndStatus(Status status) { string sql = String.Format("{0} AND Clients.Status=@1 {1}", _selectClause, _orderbyClause); // using external relator // return Db.Fetch&lt;Client, Event, Client&gt;(new ClientEventRelator().MapIt, // sql, _tenantResolver.CurrentTenantId, status); return Db.Fetch&lt;Client, Event&gt;(sql, _tenantResolver.CurrentTenantId, status); } </code></pre> <p>Method declarations in Petapoco.cs</p> <pre><code>public Page&lt;T&gt; Page&lt;T&gt;(long page, long itemsPerPage, string sql, params object[] args) </code></pre> <p>and</p> <pre><code>public void BuildPageQueries&lt;T&gt;(long skip, long take, string sql, ref object[] args, out string sqlCount, out string sqlPage) </code></pre> <p>both of which accept a single return type parameter.</p> <p>So I guess my question is that what's the best approach to use the Paged query functionality provided in PetaPoco with MultiPoco queries, as the method provided only works with a single return type?</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload