/// <summary> /// 异步查询数据库并将结果首行填充实体 /// </summary> /// <typeparam name="T">实体类型</typeparam> /// <param name="query">要执行的查询</param> /// <param name="token">取消指示</param> /// <param name="converter">异步实体转换方法</param> /// <returns>实体</returns> public async static Task <T> ExecuteEntityAsync <T>(this IDbExecutableQuery query, CancellationToken token, Func <DataRow, CancellationToken, Task <T> > converter) { var dataItem = await query.ExecuteFirstRowAsync(token); return(await converter(dataItem, token)); }
/// <summary> /// 查询数据库并将结果首行填充实体 /// </summary> /// <typeparam name="T">实体类型</typeparam> /// <param name="query">要执行的查询</param> /// <param name="token">取消指示</param> /// <returns>实体</returns> public async static Task <T> ExecuteEntityAsync <T>(this IDbExecutableQuery query, CancellationToken token = default(CancellationToken)) where T : new() { var dataItem = await query.ExecuteFirstRowAsync(token); return(dataItem.ToEntity <T>()); }
/// <summary> /// 查询数据库并将结果首行填充实体 /// </summary> /// <typeparam name="T">实体类型</typeparam> /// <param name="query">要执行的查询</param> /// <param name="token">取消指示</param> /// <param name="converter">实体转换方法</param> /// <returns>实体</returns> public async static Task <T> ExecuteEntityAsync <T>(this IDbExecutableQuery query, CancellationToken token, IEntityConverter <T> converter) where T : new() { var dataItem = await query.ExecuteFirstRowAsync(token); return(dataItem.ToEntity <T>(converter)); }
/// <summary> /// 异步执行查询并将第一个结果集的第一条记录填充动态对象 /// </summary> /// <param name="query">要执行的查询</param> /// <returns>查询结果</returns> public static async Task <dynamic> ExecuteDynamicObjectAsync(this IDbExecutableQuery query) { var dataItem = await query.ExecuteFirstRowAsync(); return(ToDynamic(dataItem)); }