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);