summaryrefslogtreecommitdiff
path: root/slips/src/app/Marina/DataAccess/DatabaseCommand.cs
blob: f394ec02c727d1b9e30e40d8dc0ec5ef115449d1 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
using System;
using System.Data;

namespace Marina.DataAccess {
	public class DatabaseCommand : IDatabaseCommand {
		public DatabaseCommand( IDbCommand command ) {
			_command = command;
		}

		public DataTable ExecuteQuery() {
			DataTable table = new DataTable( );
			table.Load( _command.ExecuteReader( ) );
			return table;
		}

		public long ExecuteScalarQuery() {
			object scalar = _command.ExecuteScalar( );
			return DBNull.Value != scalar ? Convert.ToInt32( scalar ) : -1;
		}

		private readonly IDbCommand _command;
	}
}