sharp-chat/SharpChat.Common/Database/Null/NullDatabaseCommand.cs

48 lines
1.4 KiB
C#
Raw Normal View History

2022-08-30 15:05:29 +00:00
using System;
namespace SharpChat.Database.Null {
public class NullDatabaseCommand : IDatabaseCommand {
public IDatabaseConnection Connection { get; }
public string CommandString => string.Empty;
public int CommandTimeout { get => -1; set { } }
public NullDatabaseCommand(NullDatabaseConnection conn) {
Connection = conn ?? throw new ArgumentNullException(nameof(conn));
}
public IDatabaseParameter AddParameter(string name, object value)
=> new NullDatabaseParameter();
public IDatabaseParameter AddParameter(string name, DatabaseType type)
=> new NullDatabaseParameter();
public IDatabaseParameter AddParameter(IDatabaseParameter param) {
if(param is not NullDatabaseParameter)
throw new InvalidParameterClassTypeException();
return param;
}
public void AddParameters(IDatabaseParameter[] @params) {}
public void ClearParameters() {}
public void Dispose() {
GC.SuppressFinalize(this);
}
public int Execute() {
return 0;
}
public IDatabaseReader ExecuteReader() {
return new NullDatabaseReader();
}
public object ExecuteScalar() {
return null;
}
public void Prepare() {}
}
}