Created
September 12, 2013 12:39
-
-
Save jchannon/6536653 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using (var connection = new SqlConnection(ConfigurationManager.ConnectionStrings["DBConnString"].ConnectionString)) | |
{ | |
connection.Open(); | |
using (var command = new SqlCommand("SELECT * FROM Table WHERE Id IN (")) | |
{ | |
int count = 0; | |
foreach (var keyword in model.Keywords) | |
{ | |
command.Parameters.Add("@P" + count, SqlDbType.NVarChar).Value = keyword; | |
command.CommandText += ("@P" + count); | |
count++; | |
} | |
command.CommandText += ")"; | |
using (var reader = command.ExecuteReader()) | |
{ | |
while (reader.Read()) | |
{ | |
} | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment