/// <summary> /// Serialize query results as collection of elements of type <typeparamref name="T"/> /// </summary> /// <typeparam name="T"></typeparam> /// <returns>Query result</returns> public IEnumerable <T> As <T>() where T : class { var p = _a.Promise <IEnumerable <T> >(); if (p is Containing <IEnumerable <T> > c) { return(c.Get(Sql.Hash(), _description)); } IEnumerable <T> result; var cq = _runtime.Tooling.Compile(Sql); try { using (var t = _a.GetQueryTransaction()) { result = _runtime.DoQuery <T>(cq.Query, cq.Parameters); if (p is NotifyCompleted <IEnumerable <T> > nc) { nc.Fulfill($"{_description}. {cq.Query}"); } t.Commit(); } } catch (Exception ex) { if (p is Catching <IEnumerable <T> > de) { de.Fulfill(ex, $"{_description}. {cq.Query}"); } throw; } if (p is Demanding <IEnumerable <T> > d) { d.Fulfill(result, Sql.Hash(), _description); } return(result); }