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
public class Client1 | |
{ | |
private readonly string _connStr; | |
private readonly DbProviderFactory _dpf; | |
public Client1(string connStr) : this(connStr, | |
DbProviderFactories.GetFactory("System.Data.SqlClient")) | |
{} |
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
public class Client2 | |
{ | |
private readonly string _connStr; | |
private readonly DbProviderFactory _dpf; | |
public Client2(string connStr) : this(connStr, | |
DbProviderFactories.GetFactory("System.Data.SqlClient")) | |
{} |
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
public TResult Execute<T, TResult>(string spName, | |
DbParameter[] sqlParams, Func<IDbCommand, T> execute, | |
Func<T, TResult> map) | |
{ | |
using (var conn = _dpf.CreateConnection()) | |
using (var cmd = _dpf.CreateCommand()) | |
{ | |
conn.ConnectionString = _connStr; | |
conn.Open(); | |
cmd.Connection = conn; |
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
public class Database | |
{ | |
private readonly string _connStr; | |
private readonly DbProviderFactory _dpf; | |
public Database(string connStr): this(connStr, | |
DbProviderFactories.GetFactory("System.Data.SqlClient")) | |
{} |
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
public class Client4 | |
{ | |
private readonly Database _db; | |
public Client4(Database db) | |
{ | |
_db = db; | |
} | |
public IEnumerable<User> GetCompanyUsers(string company) |
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
public class StoredProcedure | |
{ | |
private readonly DbProviderFactory _dpf; | |
private readonly DbCommand _sp; | |
public StoredProcedure(DbCommand sp, DbProviderFactory dpf) | |
{ | |
_sp = sp; | |
_dpf = dpf; | |
} |
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
public TResult Execute<T, TResult>(string spName, | |
Func<StoredProcedure, StoredProcedure> configure, | |
Func<IDbCommand, T> execute, | |
Func<T, TResult> map) | |
{ | |
using (var conn = _dpf.CreateConnection()) | |
using (var cmd = _dpf.CreateCommand()) | |
{ | |
conn.ConnectionString = _connStr; | |
conn.Open(); |
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
public class Client5 | |
{ | |
private readonly Database _db; | |
public Client5(Database db) | |
{ | |
_db = db; | |
} | |
public IEnumerable<User> GetCompanyUsers(string company) |
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
public class Database | |
{ | |
private readonly string _connStr; | |
private readonly DbProviderFactory _dpf; | |
public Database(string connStr) : this(connStr, | |
DbProviderFactories.GetFactory("System.Data.SqlClient")) | |
{ } |
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
public class Incrementer : IEnumerable<int> | |
{ | |
public IEnumerator<int> GetEnumerator() | |
{ | |
return new IncrementingEnumerator(); | |
} | |
IEnumerator IEnumerable.GetEnumerator() | |
{ | |
return GetEnumerator(); |
OlderNewer