Documentation

Query

Run Method

Syntax:

public IEnumerable<T> Run<T>(string sql, dynamic parameters = null)

Parameters:

Parameter Type Description
sql string The SQL to execute
parameters dynamic A dynamic object containing additional parameters, if any

Return value:

Type Description
IEnumerable<T> The enumerable list of returned objects represented by T
 

Examples:

@{
    // select birthdays for the current month for users in the system
    var users = Query.Run<dynamic>("select u.ContentId, FirstName, LastName, Birthday from [user] u inner join content c on u.contentid = c.contentid where c.deleted = 0 and u.isactive = 1 and u.BirthdayDisplay <> 3 and month(birthday) = month(getutcdate()) order by day(birthday) asc"); 

&lt;ul&gt;
@foreach(var user in users)
{
      &lt;li&gt;@user.FirstName @user.LastName: @user.Birthday.ToShortDateString()&lt;/li&gt;
}
&lt;/ul&gt;

}


Dynamic objects returned will have case-sensitive properties exactly as they are constructed in the select for the query.