标签:pre set ble format each tostring add groupby row
var sql = @"update [TABLE] WITH (ROWLOCK) SET 匹配方式 = ‘{0}‘ where ID in({1})"; //lissqls 是你要分组的泛型集合 var GroupList = lissqls.GroupBy(x => x.MatchType).Select(x => new{ MatchType = x.Key, ItemIDLis = x.ToList() }); //存储更新语句 List<string> update_bill_sql = new List<string>(); foreach (var item in GroupList) { List<int> itemids = new List<int>(); foreach (var itemID in item.ItemIDLis) { itemids.Add(itemID.ItemID); } var newsql = string.Format(sql, item.MatchType, string.Join(",", Array.ConvertAll<int, string>(itemids.ToArray(), delegate (int x) { return x.ToString(); }))); update_bill_sql.Add(newsql); }
标签:pre set ble format each tostring add groupby row
原文地址:https://www.cnblogs.com/ReAiQingYi/p/14712994.html