You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository has been archived by the owner on Dec 29, 2020. It is now read-only.
Trevor Pilley edited this page Mar 13, 2020
·
3 revisions
MicroLite supports returning unmapped pocos (read-only classes), this allows you to project query results into a custom strongly typed object which doesn't map directly to a single table (or is just a subset of the columns in a table).
Pocos can be used with the following methods:
ISession.Include.Many<T>();
ISession.Include.Single<T>(SqlQuery);
ISession.FetchAsync<T>();
ISession.PagedAsync<T>();
ISession.SingleAsync<T>(SqlQuery);
Example
// Convention mapped read-only class (no identifier required)publicclassCustomerSummary{publicstringName{get;set;}publicintAge{get;set;}}
var sqlQuery = new SqlQuery(
"SELECT Name, Age FROM Customer WHERE CustomerId = @p0",
1024);
var customerSummary = await session.SingleAsync<CustomerSummary>(sqlQuery);
Console.WriteLine(customerSummary.Name);
Console.WriteLine(customerSummary.Age);