Build Where Clause Dynamically in Ado.net C#

后端 未结 2 1634
梦毁少年i
梦毁少年i 2021-01-18 19:30

I will be taking in around 1000 records at a given time and I have to determine if they are existing records or new records.

If they are existing I have to update th

2条回答
  •  臣服心动
    2021-01-18 20:06

    I can only help you to write query for your request

            var recordCount = 1000;
            var query = "SELECT * FROM TableName WHERE";
            for (var i = 1; i < recordCount - 2; i += 3)
            {
                query += " (columnA = " + i + " and ColumnB = " + (i + 1) + " and ColumnC = " + (i + 2) + ") or ";
            }
    

提交回复
热议问题