Skip to content
Advertisement

Tag: foreach

Build efficient SQL statements with multiple parameters in C#

I have a list of items with different ids which represent a SQL table’s PK values. Is there any way to build an efficient and safe statement? Since now I’ve always prepared a string representing the statement and build it as I traversed the list via a foreach loop. Here’s an example of what I’m doing: Which feels very unsafe

Advertisement