惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

aimingoo的专栏
aimingoo的专栏
V
V2EX
G
Google Developers Blog
F
Full Disclosure
Martin Fowler
Martin Fowler
宝玉的分享
宝玉的分享
H
Hacker News: Front Page
Exploit-DB.com RSS Feed
Exploit-DB.com RSS Feed
NISL@THU
NISL@THU
G
GRAHAM CLULEY
V
Vulnerabilities – Threatpost
Hacker News - Newest:
Hacker News - Newest: "LLM"
A
About on SuperTechFans
The Cloudflare Blog
C
Cisco Blogs
D
DataBreaches.Net
Threat Intelligence Blog | Flashpoint
Threat Intelligence Blog | Flashpoint
Vercel News
Vercel News
P
Privacy International News Feed
Microsoft Security Blog
Microsoft Security Blog
Help Net Security
Help Net Security
Recorded Future
Recorded Future
PCI Perspectives
PCI Perspectives
S
Schneier on Security
AI
AI
N
News | PayPal Newsroom
雷峰网
雷峰网
C
Cyber Attacks, Cyber Crime and Cyber Security
P
Proofpoint News Feed
The Last Watchdog
The Last Watchdog
L
LINUX DO - 最新话题
Hugging Face - Blog
Hugging Face - Blog
Apple Machine Learning Research
Apple Machine Learning Research
Schneier on Security
Schneier on Security
S
Securelist
云风的 BLOG
云风的 BLOG
Stack Overflow Blog
Stack Overflow Blog
博客园_首页
AWS News Blog
AWS News Blog
TaoSecurity Blog
TaoSecurity Blog
OSCHINA 社区最新新闻
OSCHINA 社区最新新闻
Recent Commits to openclaw:main
Recent Commits to openclaw:main
博客园 - 三生石上(FineUI控件)
C
CXSECURITY Database RSS Feed - CXSecurity.com
K
KPMG report finds enterprise disconnect between AI and its ROI | CIO
Cloudbric
Cloudbric
C
Cybersecurity and Infrastructure Security Agency CISA
Project Zero
Project Zero
C
Check Point Blog
S
Security Affairs

博客园 - chengeng

让SVN可以修改提交log Python开发环境搭建 ubuntu 安装mysql Android Studio汉化备忘 DataConvert VS2022,IF条件为Flase也进入断点,设置方法 在CentOS上,查看CPU、内存和磁盘的指标命令 mysql 常用语句 MQTT服务器订阅消息例子 Java 异步调用方法 修改Web.config,IIS启动速度提升60倍 Windows smbv1共享协议开启 windows 10 激活 c#将一个类型对象数据赋值到另一个类型对象(名字相同的情况) 根据json内容更新表的一行,字段数量不固定,但名称需要一致 Windows 服务启动共享目录 FastReport 打印弹框,无法关闭(自己特定的场景,做个备忘,请勿参考) WinForm 指定时间没有操作键盘鼠标,弹出屏幕保护 MDns C# 实现 Makaretu.Dns.Multicast WinForm截屏 金蝶云星空BOS平台官网知识 .Net Framework 离线安装包
C#根据json内容动态生成SQL语句,字段数量可以不一样
chengeng · 2023-11-13 · via 博客园 - chengeng
public static int Update(string strJson) 
{
    int count = 0;
    List<Dictionary<string, object>> listRows = JsonConvert.DeserializeObject<List<Dictionary<string, object>>>(strJson);
    foreach (var row in listRows)
    {
        var dic = row.ToDictionary(item => item, item => true);
        string strUpdateKey = "";
        string strUpdateKeyValue = "";

        StringBuilder sb_Set = new StringBuilder("");
        foreach (var col in dic)
        {
            string strKey = col.Key.Key;
            string strValue = col.Key.Value.ToString();

            // 用于where字段和值的保存
            if (strKey == "KeyID") {
                strUpdateKey = strKey;
                strUpdateKeyValue = strValue;
            }
            if (strKey == "terminalWorkOrderProductionWeftinfoVoList")
            {
                continue;
            }

            if (sb_Set.ToString() == "")
            {
                sb_Set.Append(string.Format(strKey + "='{0}'", strValue));
            }
            else {
                sb_Set.Append(string.Format(","+strKey + "='{0}'", strValue));
            }
        }

        string strWhere = string.Format(" where {0} = '{1}';", strUpdateKey, strUpdateKeyValue);
        StringBuilder sb_Sql = new StringBuilder("update ProductPlan set ");
        sb_Sql.Append(sb_Set.ToString());
        sb_Sql.Append(strWhere);
        count = count + SQLiteHelper.ExecuteNonQuery(sb_Sql.ToString());
    }
    return count;
}

posted @ 2023-11-13 14:16  chengeng  阅读(152)  评论()    收藏  举报