/// <summary> /// 返回序列的唯一元素;如果该序列并非恰好包含一个元素,则会引发异常。 /// </summary> /// <typeparam name="T"></typeparam> /// <param name="queryable"></param> /// <param name="expression"></param> /// <returns></returns> public static bool Any <T>(this Queryable <T> queryable, Expression <Func <T, bool> > expression) { var type = queryable.Type; queryable.WhereIndex = queryable.WhereIndex + 100; ResolveExpress re = new ResolveExpress(queryable.WhereIndex); re.ResolveExpression(re, expression); queryable.Where.Add(re.SqlWhere); queryable.Params.AddRange(re.Paras); return(queryable.Count() > 0); }
/// <summary> /// 确定序列是否包含任何元素 /// </summary> /// <typeparam name="T"></typeparam> /// <param name="queryable"></param> /// <returns></returns> public static bool Any <T>(this Queryable <T> queryable) { return(queryable.Count() > 0); }