/// <summary> /// Executes the specified SQL command text and binds the first row /// selected to the specified type. If no rows are returned or if the /// value of a simple type is null, the value specified by the default /// result parameter will be returned instead. /// </summary> /// <typeparam name="T">Result type.</typeparam> /// <param name="context">A SQL command context which includes a SELECT command.</param> /// <param name="defaultResult">Value to return in case no data is present.</param> /// <param name="collections">A list of IEnumerable property selectors that should be populated from the command. /// These properties should appear in the same order as their select command.</param> /// <returns>The result of the SQL command.</returns> /// <param name="cancel">A token to monitor for cancellation requests.</param> /// <exception cref="System.InvalidOperationException">Each collection argument must have a corresponding select command.</exception> internal Task <T> ExecuteResultAsync <T>(IContext context, T defaultResult, IEnumerable <PropertyInfo> collections, CancellationToken cancel) { var processor = new SingleResultProcessor <T>(defaultResult, collections); return(RunCommandAsync <T>(context, processor, cancel)); }
/// <summary> /// Executes the specified SQL command text and binds the first row /// selected to the specified type. If no rows are returned or if the /// value of a simple type is null, the value specified by the default /// result parameter will be returned instead. /// </summary> /// <typeparam name="T">Result type.</typeparam> /// <param name="context">A SQL command context which includes a SELECT command.</param> /// <param name="defaultResult">Value to return in case no data is present.</param> /// <param name="collections">A list of IEnumerable property selectors that should be populated from the command. /// These properties should appear in the same order as their select command.</param> /// <returns>The result of the SQL command.</returns> /// <exception cref="System.InvalidOperationException">Each collection argument must have a corresponding select command.</exception> internal T ExecuteResult <T>(IContext context, T defaultResult, IEnumerable <PropertyInfo> collections) { var processor = new SingleResultProcessor <T>(defaultResult, collections); return(RunCommand <T>(context, processor)); }