zoukankan      html  css  js  c++  java
  • 接"抛砖引玉"

    接上次,考虑到转DataTable实际性能问题,我把本地LINQ复杂对象不转成DataTable,仅去掉中间的复杂对象.
    这样List<TEntity>就可以在WebService中传递了.同样抛砖引玉:-)

     1public static List<TEntity> ToGeneralList<TEntity>(this IList<TEntity> list) where TEntity : IMyCustomObject
     2        {
     3            Type type = typeof(TEntity);
     4            System.Reflection.PropertyInfo[] infos = type.GetProperties();
     5            foreach (System.Reflection.PropertyInfo info in infos)
     6            {
     7                if (info.GetCustomAttributes(typeof(System.Data.Linq.Mapping.ColumnAttribute), false).Length < 1)
     8                {
     9                    if (info.CanWrite)
    10                    {
    11                        foreach (TEntity entity in list)
    12                        {
    13                            info.SetValue(entity, nullnull);
    14                        }

    15                    }

    16                }

    17            }

    18
    19            return (List<TEntity>)list;
    20        }

    实际转换102000条数的表[12列.含三个复杂对象],设置所需时间106毫秒.

  • 相关阅读:
    【进阶指南学习笔记】lowbit
    POJ2288 Islands and bridges 【状态压缩,计数】
    POJ1995 Raising Modulo Numbers 快速幂
    CH0103 最短Hamilton路径 状态压缩
    【转载】bitset的用法 by 自为风月马前卒
    pytorch | A 60 MINUTE BLITZ 代码+详细注释
    NOI2019 游记
    十二省联考2019 游记
    python 从其他文件中引用函数
    HDU 6231 K-th Number
  • 原文地址:https://www.cnblogs.com/apexchu/p/1231959.html
Copyright © 2011-2022 走看看