using System;
using System.Collections.Generic;
using System.Data.Common;
using Sarand.Net.Standard.Base.Bus;
using Sarand.Net.Standard.Base.Core;
namespace Sarand.Net.Standard.Base.Dbas
{
//=======================================================================
// Definitions.
public enum DbmsType
{
General = 0,
Access = 10,
MsSql,
MySql,
Oracle,
Pervasive,
Dbase,
FoxPro,
Paradox,
Interbase,
/// Sage db - No 'AS' in table alias, no 'OUTER' in join type.
Sage,
QBooks,
SybaseAdvantage,
}
public enum SelectLockMode
{
/// No specific lock mode requested - use DBMS default.
Default,
/// Shared locks (MSSQL default). [MSSQL]
ReadCommitted,
/// Dirty reads - no locking. [MSSQL]
ReadUncommitted,
/// Locks all data in query. [MSSQL]
RepeatableRead,
/// Range lock on data preventing modifications. [MSSQL]
Serializable,
};
/// Reserved word delimiters - used by database definitions.
public enum DbReservedWordDelim
{
None,
SquareBrackets,
DoubleQuotes
};
public enum DbGetValueType { eDbValueSum, eDbValueMin, eDbValueMax };
//=======================================================================
public interface ISacsDatabase : ISacsStateItem
{
//-------------------------------------------------------------------
// Database properties.
String ConnectionString { get; }
DbmsType DbmsType { get; }
String DatabaseName { get; }
SelectLockMode SelectLockMode { get; set; }
bool DisplayErrors { get; set; }
DbConnection CreateConnection(bool forceOdbc = false);
//-------------------------------------------------------------------
// Identity generation.
SysId GetNextId(String objectName, DbUpdateInfo dbUpdateInfo, bool databaseTable = true, String idColumn = "Id");
int GetNextIdFromTable(String objectName, String idColumn = "Id");
bool SetMinNextId(String objectName, SysId id, DbUpdateInfo dbUpdateInfo, bool databaseTable = true, String idColumn = "Id", bool force = false);
//-------------------------------------------------------------------
// Database schema.
List GetTableNames (bool refresh = false);
List GetTableDfns (bool refresh = false);
DbDfnTable GetTableDfn (String name, bool refresh = false);
bool TableExists (String tableName);
bool ColumnExists (String tableName, String columnName);
bool IndexExists (String tableName, String indexName);
// Database info - schema summary.
IDatabaseInfo CreateDbInfo();
//-------------------------------------------------------------------
// Query records.
String GetSelectQueryPrefix ();
IDbDataTable ExecuteQuery (String query);
int ExecuteNonQuery (String query);
int ExecuteInsert (String tableName, List columnNameValues);
int ExecuteUpdate (String tableName, List columnNameValues, String filter);
int ExecuteDelete (String tableName, String filter);
// Specific queries.
long GetRowCount (String tableName, String filter);
DataValue GetRowValue (String tableName, String columnName, String filter);
DataValue GetRowValue (String tableName, String columnName, String filter, DbGetValueType getValueType);
//-------------------------------------------------------------------
}
//=======================================================================
}