Laughing
解决Oracle in 超过1000个问题 C#拼接字符串
10/21
本文最后更新于2021年04月27日,已超过1241天没有更新。如果文章内容或图片资源失效,请留言反馈,我会及时处理,谢谢!
private string getOracleSQLIn(string[] ids, string field)
{
int count = Math.Min(ids.Length, 1000);
int len = ids.Length;
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 fromIndex = i * count;
int toIndex = Math.Min(fromIndex + count, len);
string productId = string.Join("','", getArrayValues(fromIndex, toIndex, ids).ToArray());
if (i != 0)
{
builder.Append(" or ");
}
builder.Append(field).Append(" in ('").Append(productId).Append("')");
}
return builder.ToString();
}
public List<string> getArrayValues(int fromindex, int toindex, string[] array)
{
List<string> listret = new List<string>();
for (int i = fromindex; i < toindex; i++)
{
listret.Add(array[i]);
}
return listret;
}
版权属于:
香草物语
本文链接:
https://www.xiangcaowuyu.net/java/resolve-oracle-in-more-than-1000-csharp-string-split.html(转载时请注明本文出处及文章链接)
作品采用:
你好
言简意赅。https://repostone.home.blog/