惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

腾讯CDC
Schneier on Security
Schneier on Security
B
Blog RSS Feed
aimingoo的专栏
aimingoo的专栏
P
Proofpoint News Feed
A
About on SuperTechFans
Recorded Future
Recorded Future
Recent Announcements
Recent Announcements
Microsoft Security Blog
Microsoft Security Blog
L
LangChain Blog
Hugging Face - Blog
Hugging Face - Blog
The GitHub Blog
The GitHub Blog
Google DeepMind News
Google DeepMind News
T
Tailwind CSS Blog
Vercel News
Vercel News
H
Hackread – Cybersecurity News, Data Breaches, AI and More
MyScale Blog
MyScale Blog
V2EX - 技术
V2EX - 技术
N
Netflix TechBlog - Medium
F
Fortinet All Blogs
V
Visual Studio Blog
Martin Fowler
Martin Fowler
K
KPMG report finds enterprise disconnect between AI and its ROI | CIO
博客园 - Franky
freeCodeCamp Programming Tutorials: Python, JavaScript, Git & More
T
The Exploit Database - CXSecurity.com
F
Full Disclosure
Scott Helme
Scott Helme
H
Heimdal Security Blog
博客园 - 叶小钗
Google DeepMind News
Google DeepMind News
Cyberwarzone
Cyberwarzone
Application and Cybersecurity Blog
Application and Cybersecurity Blog
V
Vulnerabilities – Threatpost
Blog — PlanetScale
Blog — PlanetScale
Security Latest
Security Latest
WordPress大学
WordPress大学
Cyber Security Advisories - MS-ISAC
Cyber Security Advisories - MS-ISAC
T
Troy Hunt's Blog
S
SegmentFault 最新的问题
Forbes - Security
Forbes - Security
Jina AI
Jina AI
S
Securelist
小众软件
小众软件
Simon Willison's Weblog
Simon Willison's Weblog
J
Java Code Geeks
AWS News Blog
AWS News Blog
N
News and Events Feed by Topic
博客园 - 三生石上(FineUI控件)
量子位

博客园 - JJ.Net

正在还原 PowerDesign Comment显示 with(nolock) for xml path 某个sql帖子的答题 JQuery hide JQuery tr 循环,删除td JQuery Disabled QueryString大小设置 Silverlight HelloWorld MVC控制器跳转 JQuery选择器倒数 最后一行所有td加粗 Linq之OrderBy 循环初始化主从表数据 JQuery之Trim List<T>根据条件直接修改 JQuery选择器之has Sqlserver模拟Sequence
List自增Identity列
JJ.Net · 2015-03-23 · via 博客园 - JJ.Net
/// <summary>
    /// 转换实体类列表,增加自增列
    /// </summary>
    /// <typeparam name="T">原始实体类</typeparam>
    /// <typeparam name="U">目标实体类</typeparam>
    public class Class1<T,U>
    {
        /// <summary>
        /// 增加自增列
        /// </summary>
        /// <param name="list">原实体类列表</param>
        /// <param name="intIndentityColumnName">自增列名</param>
        /// <param name="initialValue">自增初始值</param>
        /// <returns></returns>
        public IList<U> AddIntIndentityColumn(IList<T> list, string intIndentityColumnName, int initialValue)
        {
            IList<U> listU = new List<U>();
            Type type = typeof(T);
            Type typeU = typeof(U);
            PropertyInfo[] props = type.GetProperties(BindingFlags.Public | BindingFlags.Instance);
            int i = initialValue;
            foreach (T t in list)
            {                
                Type coltype = t.GetType();
                object object_u = Activator.CreateInstance(typeU);
                foreach (PropertyInfo p in props)
                {                    
                    object o = t.GetType().GetProperty(p.Name).GetValue(t, null);
                    object_u.GetType().GetProperty(p.Name).SetValue(object_u,o,null);
                }
                ++i;
                object_u.GetType().GetProperty(intIndentityColumnName).SetValue(object_u, i, null);
                listU.Add((U)object_u);
            }            
            return listU;
        }
    }