예제 #1
0
 /// <summary>
 /// 分批循环数据 (分批集合, 第1条开始, 到第size条结束)
 /// </summary>
 /// <typeparam name="T"></typeparam>
 /// <param name="source"></param>
 /// <param name="size">分批大小</param>
 /// <param name="action">分批集合, 第几条开始, 到第几条结束</param>
 public static void ForBatch <T>(this List <T> source, int size, Action <List <T>, int, int> action)
 {
     ListHelper.ForBatch(source, size, action);
 }
예제 #2
0
 /// <summary>
 /// 多线程遍历
 /// </summary>
 /// <typeparam name="T"></typeparam>
 /// <param name="source"></param>
 /// <param name="action">委托方法</param>
 public static void ForeachAsync <T>(this IEnumerable <T> source, Action <T> action) where T : new()
 {
     ListHelper.ForeachAsync(source, action);
 }
예제 #3
0
 /// <summary>
 /// 本列表排除另外一个列表数据(可以是匿名对象)
 /// </summary>
 /// <typeparam name="TSource">数据源类型</typeparam>
 /// <typeparam name="TTarget">排除数据类型</typeparam>
 /// <typeparam name="TType">对比类型</typeparam>
 /// <param name="source">数据源</param>
 /// <param name="target">排除数据</param>
 /// <param name="sourceFunc">可以是匿名对象</param>
 /// <param name="targetFunc">可以是匿名对象</param>
 /// <returns></returns>
 public static IEnumerable <TSource> Except <TSource, TTarget, TType>(this IEnumerable <TSource> source,
                                                                      IEnumerable <TTarget> target, Func <TSource, TType> sourceFunc, Func <TTarget, TType> targetFunc)
 {
     return(ListHelper.Except(source, target, sourceFunc, targetFunc));
 }
예제 #4
0
 /// <summary>
 /// list的字段filed集合任意包含ids
 /// </summary>
 /// <typeparam name="T"></typeparam>
 /// <param name="list"></param>
 /// <param name="filed"></param>
 /// <param name="ids"></param>
 /// <param name="split">默认值:new[] { ';' }</param>
 /// <returns></returns>
 public static List <T> IsContains <T>(this List <T> list, Func <T, string> filed, List <string> ids, char[] split = null)
 {
     return(ListHelper.IsContains(list, filed, ids, split));
 }
예제 #5
0
 /// <summary>
 /// 对象去重
 /// </summary>
 /// <typeparam name="T"></typeparam>
 /// <param name="list"></param>
 /// <param name="comparer">对比委托</param>
 /// <returns></returns>
 public static IEnumerable <T> ToDist <T>(this IEnumerable <T> list, Func <T, T, bool> comparer) where T : new()
 {
     return(ListHelper.ToDist(list, comparer));
 }
예제 #6
0
 /// <summary>
 /// 转Dictionary(可以做去重处理)
 /// </summary>
 /// <typeparam name="T"></typeparam>
 /// <typeparam name="TKey"></typeparam>
 /// <typeparam name="TValue"></typeparam>
 /// <param name="list"></param>
 /// <param name="key">字段:p=>p.string</param>
 /// <param name="value"></param>
 /// <param name="useFirstValue">重复使用值规则:true使用第一个值;false使用最后一个值</param>
 /// <param name="comparer">不区分大小写:StringComparer.OrdinalIgnoreCase;区分大小写:StringComparer.Ordinal</param>
 /// <returns></returns>
 public static Dictionary <TKey, TValue> ToDict <T, TKey, TValue>(this IEnumerable <T> list, Func <T, TKey> key, Func <T, TValue> value, bool useFirstValue, IEqualityComparer <TKey> comparer = null)
 {
     return(ListHelper.ToDict(list, key, value, useFirstValue, comparer));
 }
예제 #7
0
 /// <summary>
 /// 获取重复数据(TKey必须是匿名对象)
 /// </summary>
 /// <typeparam name="T"></typeparam>
 /// <typeparam name="TKey">TKey必须是匿名对象</typeparam>
 /// <param name="list"></param>
 /// <param name="key"></param>
 /// <param name="comparer"></param>
 /// <returns></returns>
 public static IEnumerable <T> GetRepeatLists <T, TKey>(this IEnumerable <T> list, Func <T, TKey> key, IEqualityComparer <TKey> comparer = null)
 {
     return(ListHelper.GetRepeatLists(list, key, comparer));
 }
예제 #8
0
 public static IEnumerable <TKey> ToDist <T, TKey>(this IEnumerable <T> list, Func <T, TKey> key, IEqualityComparer <TKey> comparer = null)
 {
     return(ListHelper.ToDist(list, key, comparer));
 }
예제 #9
0
 /// <summary>
 /// 是否有重复数据(TKey必须是匿名对象)
 /// </summary>
 /// <typeparam name="T"></typeparam>
 /// <typeparam name="TKey">TKey必须是匿名对象</typeparam>
 /// <param name="list"></param>
 /// <param name="key"></param>
 /// <param name="comparer"></param>
 /// <returns></returns>
 public static bool HasRepeat <T, TKey>(this IEnumerable <T> list, Func <T, TKey> key, IEqualityComparer <TKey> comparer = null)
 {
     return(ListHelper.HasRepeat(list, key, comparer));
 }
예제 #10
0
        /// <summary>
        /// 移除两边都是一条记录的数据
        /// </summary>
        /// <typeparam name="TLeft"></typeparam>
        /// <typeparam name="TRight"></typeparam>
        /// <typeparam name="TEquals"></typeparam>
        /// <param name="leftList"></param>
        /// <param name="rightList"></param>
        /// <param name="leftFunc"></param>
        /// <param name="rightFunc"></param>
        /// <returns></returns>
        public static ListComparerParam <TLeft, TRight, TEquals> RemoveSameOneRecord <TLeft, TRight, TEquals>(this IEnumerable <TLeft> leftList, IEnumerable <TRight> rightList, Func <TLeft, TEquals> leftFunc, Func <TRight, TEquals> rightFunc)
        {
            var param = new ListComparerParam <TLeft, TRight, TEquals>(leftList, rightList, leftFunc, rightFunc);

            return(ListHelper.RemoveSameOneRecord(param));
        }
예제 #11
0
        /// <summary>
        /// 返回两列表差异数据集合(包含重复数据的数量对比)
        /// </summary>
        /// <typeparam name="TLeft"></typeparam>
        /// <typeparam name="TRight"></typeparam>
        /// <typeparam name="TEquals"></typeparam>
        /// <param name="leftList"></param>
        /// <param name="rightList"></param>
        /// <param name="leftFunc"></param>
        /// <param name="rightFunc"></param>
        /// <param name="isBigData">是否是处理大数据</param>
        /// <returns></returns>
        public static ListDiffResult <TLeft, TRight, TEquals> GetDiffList <TLeft, TRight, TEquals>(this IEnumerable <TLeft> leftList, IEnumerable <TRight> rightList, Func <TLeft, TEquals> leftFunc, Func <TRight, TEquals> rightFunc, bool isBigData)
        {
            var param = new ListComparerParam <TLeft, TRight, TEquals>(leftList, rightList, leftFunc, rightFunc);

            return(ListHelper.GetDiffList(param, isBigData));
        }
예제 #12
0
 /// <summary>
 /// List转DataTable
 /// </summary>
 /// <typeparam name="T"></typeparam>
 /// <param name="source"></param>
 /// <returns></returns>
 public static DataTable ToDataTable <T>(this IEnumerable <T> source)
 {
     return(ListHelper.ToDataTable(source));
 }
예제 #13
0
 /// <summary>
 /// DataTable转List
 /// </summary>
 /// <typeparam name="T"></typeparam>
 /// <param name="dt"></param>
 /// <returns></returns>
 public static List <T> ToList <T>(this DataTable dt) where T : new()
 {
     return(ListHelper.ToList <T>(dt));
 }