예제 #1
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());
        }
예제 #2
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>());
        }