Skip to content

Instantly share code, notes, and snippets.

@gethari
Created August 13, 2019 05:06
Show Gist options
  • Save gethari/2125154951159dcdb814da80495b83d2 to your computer and use it in GitHub Desktop.
Save gethari/2125154951159dcdb814da80495b83d2 to your computer and use it in GitHub Desktop.
public async Task<List<KeyValuePair<string, string>>> WithoutDapper(Guid id)
{
using (var connection = new SqlConnection(ConnectionString))
{
List<KeyValuePair<string, string>> propertiesList = new List<KeyValuePair<string, string>>();
SqlCommand command = new SqlCommand(queryString, connection);
command.Parameters.AddWithValue("Id", id);
connection.Open();
SqlDataReader reader = await command.ExecuteReaderAsync();
if (reader.HasRows)
{
while (reader.Read())
{
propertiesList.Add(new KeyValuePair<string, string>(
reader["Name"].ToString(),
reader["Type"].ToString()));
}
}
return propertiesList;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment