TypechoJoeTheme

香草物语

统计
登录
用户名
密码
/
注册
用户名
邮箱
输入密码
确认密码

解决Oracle in 超过1000个问题 C#拼接字符串

Laughing博主
2018-10-21
/
0 评论
/
1,087 阅读
/
0 个字
/
百度已收录
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;  
        }
朗读
赞(0)
赞赏
感谢您的支持,我会继续努力哒!
版权属于:

香草物语

本文链接:

https://www.xiangcaowuyu.net/java/resolve-oracle-in-more-than-1000-csharp-string-split.html(转载时请注明本文出处及文章链接)

评论 (0)
  1. SZQ 闲逛
    Windows 10 · Google Chrome

    你好

    2019-12-20 回复
  2. repostone 闲逛
    Windows 8.1 · Google Chrome

    言简意赅。https://repostone.home.blog/

    2019-05-12 回复