Skip to content

Commit ddcd244

Browse files
committed
- guarded query
1 parent 695d7f9 commit ddcd244

File tree

1 file changed

+9
-0
lines changed

1 file changed

+9
-0
lines changed

Shuttle.Core.Data/DatabaseGateway.cs

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
using System.Data;
44
using System.Linq;
55
using System.Text;
6+
using Shuttle.Core.Contract;
67
using Shuttle.Core.Logging;
78

89
namespace Shuttle.Core.Data
@@ -18,6 +19,8 @@ public DatabaseGateway()
1819

1920
public DataTable GetDataTableFor(IQuery query)
2021
{
22+
Guard.AgainstNull(query, nameof(query));
23+
2124
using (var reader = GetReaderUsing(query))
2225
{
2326
var results = new DataTable();
@@ -62,6 +65,8 @@ public DataRow GetSingleRowUsing(IQuery query)
6265

6366
public IDataReader GetReaderUsing(IQuery query)
6467
{
68+
Guard.AgainstNull(query, nameof(query));
69+
6570
using (var command = GuardedDatabaseContext().CreateCommandToExecute(query))
6671
{
6772
if (Log.IsTraceEnabled)
@@ -101,6 +106,8 @@ private static IDatabaseContext GuardedDatabaseContext()
101106

102107
public int ExecuteUsing(IQuery query)
103108
{
109+
Guard.AgainstNull(query, nameof(query));
110+
104111
using (var command = GuardedDatabaseContext().CreateCommandToExecute(query))
105112
{
106113
if (Log.IsTraceEnabled)
@@ -128,6 +135,8 @@ public int ExecuteUsing(IQuery query)
128135

129136
public T GetScalarUsing<T>(IQuery query)
130137
{
138+
Guard.AgainstNull(query, nameof(query));
139+
131140
using (var command = GuardedDatabaseContext().CreateCommandToExecute(query))
132141
{
133142
if (Log.IsTraceEnabled)

0 commit comments

Comments
 (0)