/// <summary> /// 查询数据库并将结果首行填充实体 /// </summary> /// <typeparam name="T">实体类型</typeparam> /// <param name="query">要执行的查询</param> /// <param name="converter">实体转换方法</param> /// <returns>实体</returns> public static T ExecuteEntity <T>(this IDbExecutableQuery query, Func <DataRow, T> converter) { var dataItem = query.ExecuteFirstRow(); return(converter(dataItem)); }
/// <summary> /// 查询数据库并将结果首行填充实体 /// </summary> /// <typeparam name="T">实体类型</typeparam> /// <param name="query">要执行的查询</param> /// <returns>实体</returns> public static T ExecuteEntity <T>(this IDbExecutableQuery query) where T : new() { var dataItem = query.ExecuteFirstRow(); return(dataItem.ToEntity <T>()); }
/// <summary> /// 查询数据库并将结果首行填充实体 /// </summary> /// <typeparam name="T">实体类型</typeparam> /// <param name="query">要执行的查询</param> /// <param name="converter">实体转换方法</param> /// <returns>实体</returns> public static T ExecuteEntity <T>(this IDbExecutableQuery query, IEntityConverter <T> converter) where T : new() { var dataItem = query.ExecuteFirstRow(); return(dataItem.ToEntity <T>(converter)); }
/// <summary> /// 执行查询并将第一个结果集的第一条记录填充动态对象 /// </summary> /// <param name="query">要执行的查询</param> /// <returns>查询结果</returns> public static dynamic ExecuteDynamicObject(this IDbExecutableQuery query) { var dataItem = query.ExecuteFirstRow(); return(ToDynamic(dataItem)); }