using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; namespace ZD.Share.Common { public class OracleHelper { public static string GetOracleSQLIn(List ids, string field) { if (!ids.Any()) { return string.Empty; } int count = Math.Min(ids.Count, 1000); int len = ids.Count; int size = len % count; if (size == 0) { size = len / count; } else { size = (len / count) + 1; } StringBuilder builder = new StringBuilder(); for (int i = 0; i < size; i++) { int index = i * count; int toIndex = Math.Min(index + count, len); string productId = string.Join("','", GetArrayValues(index, toIndex, ids).ToArray()); if (i != 0) { builder.Append(" or "); } builder.Append(field).Append(" in ('").Append(productId).Append("')"); } return builder.ToString(); } public static List GetArrayValues(int index, int toindex, List array) { List listret = new List(); for (int i = index; i < toindex; i++) { listret.Add(array[i]); } return listret; } } }