Guest User

Untitled

a guest
Nov 17th, 2017
74
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.84 KB | None | 0 0
  1. class SqlDataContext : ISqlDataContext {
  2.  
  3. private readonly SqlConnection _connection;
  4.  
  5. public SqlDataContext(string connectionString)
  6. {
  7. _connection = CreateConnection(connectionString);
  8. }
  9.  
  10. public IDataReader ExecuteReader(string storedProcedureName, ICollection<SqlParameter> parameters)
  11. {
  12. // execute the command here using the _connection private field.
  13. // This is where your conn.Open() and "do stuff" happens.
  14. }
  15.  
  16. private SqlConnection CreateConnection(string connectionString)
  17. {
  18. if (string.IsNullOrEmpty(connectionString))
  19. {
  20. throw new ArgumentNullException("connectionString");
  21. }
  22.  
  23. return new SqlConnection(connectionString);
  24. }
  25. }
  26.  
  27. interface ISqlDataContext
  28. {
  29. IDataReader ExecuteReader(string storedProcedureName, ICollection<SqlParameter> parameters);
  30. }
Add Comment
Please, Sign In to add comment