//------------------------------------------------------------------------------
//
// This code was generated by a code generation tool.
// Date generated: 14/05/2018 17:05:24
//
// Changes to this file may cause incorrect behavior and will be lost if
// the code is regenerated.
//
//------------------------------------------------------------------------------
using ConanData.Database;
using ConanData.Datasets;
using System;
using System.Data;
using System.Data.Common;
using System.Data.OleDb;
using System.Text;
namespace ConanData.DataAccess.Base
{
///
/// Data access class to perform Fetches, Deletes, Inserts and Updates
/// on table account
///
internal class AccountDataAccessBase
{
#region Constants
internal const String SCHEMA__NAME = "";
internal const String TABLE__NAME = "account";
internal const String COLUMN__ID = "id";
internal const String COLUMN__USER = "user";
internal const String COLUMN__ONLINE = "online";
#endregion
private Connection _connection = null;
public AccountDataAccessBase(Connection connection)
{
_connection = connection;
}
#region Properties
public Connection Connection => _connection;
#endregion
#region Fetch Typed DataSets
///
/// Fetches all the records into a typed dataset from the
/// table account
///
/// A populated typed dataset
public AccountDataSet FetchDataSetAll()
{
Connection connection = Connection;
StringBuilder sql = new StringBuilder();
sql.Append(GetSelect());
AccountDataSet dataSet = new AccountDataSet();
connection.FillDataSet(sql.ToString(), null, CommandType.Text, 300, dataSet, new String[] { TABLE__NAME });
return dataSet;
}
#endregion
#region Fetch DataTables
///
/// Fetches all the records into an untyped datatable from the
/// table account
///
/// A populated untyped datatable
public DataTable FetchDataTableAll()
{
Connection connection = Connection;
StringBuilder sql = new StringBuilder();
sql.Append(GetSelect());
return connection.ExecuteDataTable(sql.ToString(), null, CommandType.Text, 300, TABLE__NAME);
}
#endregion
#region Support Methods
protected String GetSelect()
{
StringBuilder sql = new StringBuilder();
sql.AppendFormat("SELECT [{0}].[{1}] AS [AccountId],", TABLE__NAME, COLUMN__ID);
sql.AppendFormat("[{0}].[{1}] AS [User],", TABLE__NAME, COLUMN__USER);
sql.AppendFormat("[{0}].[{1}] AS [Online] ", TABLE__NAME, COLUMN__ONLINE);
sql.AppendFormat("FROM {0}[{1}] ", SCHEMA__NAME, TABLE__NAME);
return sql.ToString();
}
#endregion
}
}