pull/1/head
a.bozhenov 5 years ago
parent 7f0d63cf2b
commit f43e2dca93

@ -17,6 +17,7 @@ namespace ZeroLevel.SqlServer
void ExecuteNonResult(IEnumerable<ZSqlCommand> commands);
int ExecuteNonResult(string query);
int ExecuteNonResult(string query, DbParameter[] par);
DbReader ExecuteReader(string query, DbParameter[] par);
void LazySelect(string query, DbParameter[] par, Func<DbDataReader, bool> readHandler, int timeout);
T Read<T>(DbDataReader reader, int index);

@ -6,6 +6,31 @@ using System.Data.SqlClient;
namespace ZeroLevel.SqlServer
{
public class DbReader
:IDisposable
{
private readonly DbConnection _connection;
private readonly IDbCommand _command;
public DbReader(DbConnection connection, IDbCommand command)
{
_connection = connection;
_command = command;
}
public IDataReader GetReader()
{
return _command.ExecuteReader(CommandBehavior.CloseConnection);
}
public void Dispose()
{
_command.Dispose();
_connection.Close();
_connection.Dispose();
}
}
public class SqlDbProvider :
IDbProvider
{
@ -185,6 +210,13 @@ namespace ZeroLevel.SqlServer
}
#endregion
public DbReader ExecuteReader(string query, DbParameter[] par)
{
var connection = _factory.CreateConnection();
return new DbReader(connection, CreateCommand(connection, query, par, Timeout));
}
#region LazySelect
public void LazySelect(string query, DbParameter[] par, Func<DbDataReader, bool> readHandler, int timeout = Timeout)
{

Loading…
Cancel
Save

Powered by TurnKey Linux.