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毫秒.

  • 相关阅读:
    ASCII&Base64
    CentOS自动同步时间
    Java的HashMap
    Java线程同步操作
    Nginx基本配置与应用
    vc中调用Com组件的方法详解
    VC++ try catch (转)
    oracle中exp,imp的使用详解
    jdbc oracle 连接字符串
    标准的开源实现
  • 原文地址:https://www.cnblogs.com/apexchu/p/1231959.html
Copyright © 2011-2022 走看看