码迷,mamicode.com
首页 > 其他好文 > 详细

多条插入拼接

时间:2016-04-20 18:05:26      阅读:118      评论:0      收藏:0      [点我收藏+]

标签:

  string sql = @"update a 
                            set a.M_ParentID=b.M_ParentID,
                            a.M_Name=b.M_Name,
                            a.M_Seq=b.M_Seq,
                            a.M_IsDel=b.M_IsDel
                            from SysMenu_BySchool a
                            inner join (";
            foreach (SysMenu_BySchoolEntity m in lstMenu)
            {
                sql += string.Format("select {0} ID,{1} as M_ParentID,‘{2}‘ as M_Name,{3} as M_Seq,{4} as M_IsDel union ", m.ID, m.M_ParentID, Utils2.ValidChar(m.M_Name), m.M_Seq,m.M_IsDel.ToString());
            }
            sql = sql.TrimEnd(" union ".ToCharArray());
            sql += ") b on a.ID=b.ID";
            return dal.UpdateCommand(sql, null);

 

多条插入拼接

标签:

原文地址:http://www.cnblogs.com/muxueyuan/p/5413572.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!