예제 #1
0
        private static IList <T> MergeFirst <T>(IList <IDataReader> dataReaders, SqlTable sqlTable, Boolean isSameShard)
        {
            if (dataReaders == null || dataReaders.Count == 0)
            {
                return(null);
            }

            if (sqlTable == null || sqlTable.ColumnList == null || sqlTable.ColumnList.Count == 0)
            {
                return(null);
            }

            var funcs = new List <Func <T> >();

            for (Int32 i = 0; i < dataReaders.Count; i++)
            {
                var dataReader = dataReaders[i];
                funcs.Add(() =>
                {
                    try
                    {
                        LogManager.Logger.StartTracing();
                        T item = default(T);
                        using (dataReader)
                        {
                            OrmUtil.FillFirstByName(dataReader, sqlTable.ColumnList, ref item);
                        }
                        return(item);
                    }
                    finally
                    {
                        LogManager.Logger.StopTracing();
                    }
                });
            }

            var result = ExecuteParallelHelper.ParallelExcuter(funcs, isSameShard);

            return(result);
        }