How to add a custom column to get total rowcount when using Typed query

      var q = Db.From<MovieOffer>().Join<ProviderMovie>()
        .Where<MovieOffer>(x => request.OfferTypes.Contains(x.OfferType) && (x.Visible == true)).Skip(paging.Skip).Take(paging.Take);

What I’d like to to is to inject the below statement to include the Total Row using sql.

q.SelectExpression = q.SelectExpression + ", Count(*) OVER () as RecordCount";

This is not working as the SelectExpression reverts when executing the select statement. The SQL executes correctly but when I look at the last sql statement from the Db object, the injected sql is gone.

var avails = Db.Select<MovieAvailabilityResponse>(q);


The Select<T> API says to populate the results of the query into the MovieAvailabilityResponse models.

If you want to get the total of the query instead, use the Count API:

var total = db.Count(q);