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

  • 相关阅读:
    如何学习掌握一门新技术
    Linux多线程编程(不限Linux)
    腾讯后台开发面试题2
    腾讯后台开发面试题
    【转】Linux杀死fork产生的子进程的僵尸进程defunct
    【转】Linux网络编程入门
    【转】揭开Socket编程的面纱
    【转】简单理解socket
    【转】404、500、502等HTTP状态码介绍
    【转】fread函数和fwrite函数
  • 原文地址:https://www.cnblogs.com/apexchu/p/1231959.html
Copyright © 2011-2022 走看看