To achieve that you should define a static method in your FluentContext equivalent of the database function you want to call. This method will not be called explicitly, it is only a marker for OpenAccess to translate the method call to a function call at runtime.
public static System.DateTime GetLastActivity(int? Id)
{
throw new NotImplementedException();
}
Invoking from the context
Example:
var date = dbContext.GetLastActivity(12);
If you want to execute it that way you should use the OpenAccess ADO API to implement a non-static method in your fluent context class, like the example below:
public DateTime GetLastActivity(int? Id)
{
OAParameter parameteId = new OAParameter();
parameteId.ParameterName = "@Id";
if (Id.HasValue)
{
parameteId.Value = Id.Value;
}
else
{
parameteId.DbType = DbType.Int32;
parameteId.Value = DBNull.Value;
}
DateTime date = this.ExecuteScalar<DateTime>("SELECT `GetLastActivity`(@Id)", parameteId);
return date;
}
I hope that helps. Do not hesitate to contact us if you have other questions.
Regards,
Kaloyan Nikolov
the Telerik team
Free Webinar: OpenAccess Integration in Sitefinity. SIGN UP NOW.