Пример #1
0
        /// <summary>
        /// 获取最大值
        /// </summary>
        /// <typeparam name="T"></typeparam>
        /// <param name="thisValue"></param>
        /// <returns></returns>
        public static T Max <T>(this Taskable <T> thisValue)
        {
            var isClass = typeof(T).IsClass;

            if (isClass)
            {
                Check.Exception(isClass, "TaskExtensions.Max.thisValue T只能是为string和值类型。");
            }
            return(thisValue.Tasks.Select(it => it.Result.Value).Max());
        }
Пример #2
0
        /// <summary>
        /// 如果序列中不包含任何元素,则返回默认值。
        /// </summary>
        /// <typeparam name="T"></typeparam>
        /// <param name="thisValue"></param>
        /// <returns></returns>
        public static T ToFirstOrDefault <T>(this Taskable <T> thisValue) where T : class
        {
            var isClass = typeof(T).IsClass;

            if (!isClass)
            {
                Check.Exception(isClass, "TaskExtensions.ToSingle.thisValue T只能为class。");
            }
            return(thisValue.MergeEntities <T>().FirstOrDefault());
        }
Пример #3
0
        /// <summary>
        /// 将Task中的结果集合并成List集成
        /// </summary>
        /// <typeparam name="T"></typeparam>
        /// <param name="thisValue"></param>
        /// <returns></returns>
        public static List <T> ToList <T>(this Taskable <T> thisValue) where T : class
        {
            var isClass = typeof(T).IsClass;

            if (!isClass)
            {
                Check.Exception(isClass, "TaskExtensions.ToList.thisValue T只能为class。");
            }
            return(thisValue.MergeEntities <T>());
        }
Пример #4
0
        /// <summary>
        /// 将结果集合并到一个集合
        /// </summary>
        /// <typeparam name="DataTable"></typeparam>
        /// <param name="thisValue"></param>
        /// <returns></returns>
        public static IEnumerable <DataRow> MergeTable <DataTable>(this Taskable <DataTable> thisValue)
        {
            var isDataTable = typeof(System.Data.DataTable) == typeof(DataTable);

            if (!isDataTable)
            {
                Check.Exception(isDataTable, "TaskExtensions.MergeTable.thisValue T只能为DataTable。");
            }
            var reval = thisValue.Tasks.SelectMany(it => it.Result.DataTable.AsEnumerable()).ToList();

            return(reval);
        }
Пример #5
0
 /// <summary>
 ///是否存在这条记录
 /// </summary>
 /// <param name="thisValue"></param>
 /// <returns></returns>
 public static bool Any(this Taskable <int> thisValue)
 {
     return(thisValue.Tasks.Select(it => it.Result.Value).Count() > 0);
 }
Пример #6
0
        /// <summary>
        /// 将结果集合并到一个集合
        /// </summary>
        /// <typeparam name="T"></typeparam>
        /// <param name="thisValue"></param>
        /// <returns></returns>
        public static List <T> MergeValue <T>(this Taskable <T> thisValue)
        {
            var reval = thisValue.Tasks.Select(it => it.Result.Value).ToList();

            return(reval);
        }
Пример #7
0
        /// <summary>
        /// 将结果集合并到一个集合
        /// </summary>
        /// <typeparam name="T"></typeparam>
        /// <param name="thisValue"></param>
        /// <returns></returns>
        public static List <T> MergeEntities <T>(this Taskable <T> thisValue) where T : class
        {
            var reval = thisValue.Tasks.SelectMany(it => it.Result.Entities).ToList();

            return(reval);
        }
Пример #8
0
 /// <summary>
 /// 获取count
 /// </summary>
 /// <param name="thisValue"></param>
 /// <returns></returns>
 public static int Count(this Taskable <int> thisValue)
 {
     return(thisValue.Tasks.Select(it => it.Result.Value).Sum());
 }