Files
Common-VS2019/SacsStandardBase/Base/Dbas/ISacsDatabase.cs
T
2021-06-04 14:04:03 +01:00

95 lines
3.3 KiB
C#

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,
Access,
MsSql,
MySql,
Oracle,
Pervasive,
Dbase,
FoxPro,
Paradox,
Interbase,
/// <summary>No 'AS' in table alias, no 'OUTER' in join type.</summary>
Sage,
QBooks,
SybaseAdvantage,
}
public enum SelectLockMode
{
/// <summary>No specific lock mode requested - use DBMS default.</summary>
Default,
/// <summary>Shared locks (MSSQL default). [MSSQL]</summary>
ReadCommitted,
/// <summary>Dirty reads - no locking. [MSSQL]</summary>
ReadUncommitted,
/// <summary>Locks all data in query. [MSSQL]</summary>
RepeatableRead,
/// <summary>Range lock on data preventing modifications. [MSSQL]</summary>
Serializable,
};
/// <summary>Reserved word delimiters - used by database definitions.</summary>
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<String> GetTableNames (bool refresh = false);
List<DbDfnTable> 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);
//-------------------------------------------------------------------
// Query records.
String GetSelectQueryPrefix ();
IDbDataTable ExecuteQuery (String query);
int ExecuteNonQuery (String query);
int ExecuteInsert (String tableName, List<StringPair> columnNameValues);
int ExecuteUpdate (String tableName, List<StringPair> 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);
//-------------------------------------------------------------------
}
//=======================================================================
}