/// <summary> /// Query FirstOrDefault /// 匹配的第一个实体,如果没有匹配的实体,则选择默认值。 /// </summary> /// <typeparam name="TEntity">类型参数</typeparam> /// <param name="connection">DbConnection</param> /// <param name="predicate">条件表达式目录树</param> /// <returns>TEntity 集合</returns> public static TEntity FirstOrDefault <TEntity>(this IDbConnection connection, Expression <Func <TEntity, bool> > predicate) { try { return(DommelMapper.FirstOrDefault(connection, predicate)); } catch (Exception ex) { throw new Exception(ex.Message); } }