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 下用 Python 连接 MSSql Server 2008
    这周我加星(4)
    几个受益终身的英文缩写
    这周我加星(1)
    证据
    这周我加星(3)
    代友招人────3D 客户端程序员
    人在广州,力撑陈 Sir
    谁不会成为 Linux(ubuntu)的用户
    这周我加星(5)
  • 原文地址:https://www.cnblogs.com/apexchu/p/1231959.html
Copyright © 2011-2022 走看看