Associations
This commit is contained in:
@@ -1,5 +1,6 @@
|
||||
using Microsoft.Data.SqlClient;
|
||||
using Sarand.BusinessMgr.Net.Standard.Dbas.Data;
|
||||
using Sarand.Net.Standard.Base.App;
|
||||
using Sarand.Net.Standard.Base.Core;
|
||||
using Sarand.Net.Standard.Base.Dbas;
|
||||
using Sarand.Net.Standard.Base.Utils;
|
||||
@@ -9,7 +10,7 @@ using System.Data.Common;
|
||||
using System.Linq;
|
||||
|
||||
//---------------------------------------------------------------------------
|
||||
// Code generated by Sarand Database Utilities Thu 6-Jun-2024 17:06:27
|
||||
// Code generated by Sarand Database Utilities Wed 4-Dec-2024 12:38:21
|
||||
//---------------------------------------------------------------------------
|
||||
namespace Sarand.BusinessMgr.Net.Standard.Dbas.Internal
|
||||
{
|
||||
@@ -24,20 +25,20 @@ namespace Sarand.BusinessMgr.Net.Standard.Dbas.Internal
|
||||
public ColumnDataString _CodeAlt1 { get; } = new ColumnDataString("CodeAlt1");
|
||||
public ColumnDataString _CodeAlt2 { get; } = new ColumnDataString("CodeAlt2");
|
||||
public ColumnDataString _Description { get; } = new ColumnDataString("Description");
|
||||
public ColumnDataInt32 _RegionId { get; } = new ColumnDataInt32("RegionId");
|
||||
public ColumnDataDateTime _EffectFrom { get; } = new ColumnDataDateTime("EffectFrom");
|
||||
public ColumnDataDateTime _EffectTo { get; } = new ColumnDataDateTime("EffectTo");
|
||||
public ColumnDataDecimal _TaxRate { get; } = new ColumnDataDecimal("TaxRate");
|
||||
public ColumnDataDecimal _TaxRatePrev { get; } = new ColumnDataDecimal("TaxRatePrev");
|
||||
public ColumnDataInt32 _TaxCodeIdLink { get; } = new ColumnDataInt32("TaxCodeIdLink");
|
||||
public ColumnDataInt32Nullable _RegionId { get; } = new ColumnDataInt32Nullable("RegionId");
|
||||
public ColumnDataDateTimeNullable _EffectFrom { get; } = new ColumnDataDateTimeNullable("EffectFrom");
|
||||
public ColumnDataDateTimeNullable _EffectTo { get; } = new ColumnDataDateTimeNullable("EffectTo");
|
||||
public ColumnDataDecimalNullable _TaxRate { get; } = new ColumnDataDecimalNullable("TaxRate");
|
||||
public ColumnDataDecimalNullable _TaxRatePrev { get; } = new ColumnDataDecimalNullable("TaxRatePrev");
|
||||
public ColumnDataInt32Nullable _TaxCodeIdLink { get; } = new ColumnDataInt32Nullable("TaxCodeIdLink");
|
||||
public ColumnDataString _Notes { get; } = new ColumnDataString("Notes");
|
||||
public ColumnDataInt16 _Flags { get; } = new ColumnDataInt16("Flags");
|
||||
public ColumnDataInt16Nullable _Flags { get; } = new ColumnDataInt16Nullable("Flags");
|
||||
public ColumnDataString _Status { get; } = new ColumnDataString("Status");
|
||||
public ColumnDataDateTime _CreateOn { get; } = new ColumnDataDateTime("CreateOn");
|
||||
public ColumnDataInt32 _CreateBy { get; } = new ColumnDataInt32("CreateBy");
|
||||
public ColumnDataDateTimeNullable _CreateOn { get; } = new ColumnDataDateTimeNullable("CreateOn");
|
||||
public ColumnDataInt32Nullable _CreateBy { get; } = new ColumnDataInt32Nullable("CreateBy");
|
||||
public ColumnDataString _CreateHost { get; } = new ColumnDataString("CreateHost");
|
||||
public ColumnDataDateTime _UpdateOn { get; } = new ColumnDataDateTime("UpdateOn");
|
||||
public ColumnDataInt32 _UpdateBy { get; } = new ColumnDataInt32("UpdateBy");
|
||||
public ColumnDataDateTimeNullable _UpdateOn { get; } = new ColumnDataDateTimeNullable("UpdateOn");
|
||||
public ColumnDataInt32Nullable _UpdateBy { get; } = new ColumnDataInt32Nullable("UpdateBy");
|
||||
public ColumnDataString _UpdateHost { get; } = new ColumnDataString("UpdateHost");
|
||||
}
|
||||
|
||||
@@ -73,6 +74,28 @@ namespace Sarand.BusinessMgr.Net.Standard.Dbas.Internal
|
||||
{
|
||||
"Id",
|
||||
};
|
||||
protected static List<String> fieldsNullable { get; } = new List<String>()
|
||||
{
|
||||
"Code",
|
||||
"CodeAlt1",
|
||||
"CodeAlt2",
|
||||
"Description",
|
||||
"RegionId",
|
||||
"EffectFrom",
|
||||
"EffectTo",
|
||||
"TaxRate",
|
||||
"TaxRatePrev",
|
||||
"TaxCodeIdLink",
|
||||
"Notes",
|
||||
"Flags",
|
||||
"Status",
|
||||
"CreateOn",
|
||||
"CreateBy",
|
||||
"CreateHost",
|
||||
"UpdateOn",
|
||||
"UpdateBy",
|
||||
"UpdateHost",
|
||||
};
|
||||
protected static List<String> fieldsIgnoreOnUpdate { get; } = new List<String>()
|
||||
{
|
||||
"CreateOn",
|
||||
@@ -101,24 +124,25 @@ namespace Sarand.BusinessMgr.Net.Standard.Dbas.Internal
|
||||
public String _CodeAlt1 { get { return Cols._CodeAlt1.Value; } set { Cols._CodeAlt1.Value = value; } }
|
||||
public String _CodeAlt2 { get { return Cols._CodeAlt2.Value; } set { Cols._CodeAlt2.Value = value; } }
|
||||
public String _Description { get { return Cols._Description.Value; } set { Cols._Description.Value = value; } }
|
||||
public Int32 _RegionId { get { return Cols._RegionId.Value; } set { Cols._RegionId.Value = value; } }
|
||||
public DateTime _EffectFrom { get { return Cols._EffectFrom.Value; } set { Cols._EffectFrom.Value = value; } }
|
||||
public DateTime _EffectTo { get { return Cols._EffectTo.Value; } set { Cols._EffectTo.Value = value; } }
|
||||
public Decimal _TaxRate { get { return Cols._TaxRate.Value; } set { Cols._TaxRate.Value = value; } }
|
||||
public Decimal _TaxRatePrev { get { return Cols._TaxRatePrev.Value; } set { Cols._TaxRatePrev.Value = value; } }
|
||||
public Int32 _TaxCodeIdLink { get { return Cols._TaxCodeIdLink.Value; } set { Cols._TaxCodeIdLink.Value = value; } }
|
||||
public Int32? _RegionId { get { return Cols._RegionId.Value; } set { Cols._RegionId.Value = value; } }
|
||||
public DateTime? _EffectFrom { get { return Cols._EffectFrom.Value; } set { Cols._EffectFrom.Value = value; } }
|
||||
public DateTime? _EffectTo { get { return Cols._EffectTo.Value; } set { Cols._EffectTo.Value = value; } }
|
||||
public Decimal? _TaxRate { get { return Cols._TaxRate.Value; } set { Cols._TaxRate.Value = value; } }
|
||||
public Decimal? _TaxRatePrev { get { return Cols._TaxRatePrev.Value; } set { Cols._TaxRatePrev.Value = value; } }
|
||||
public Int32? _TaxCodeIdLink { get { return Cols._TaxCodeIdLink.Value; } set { Cols._TaxCodeIdLink.Value = value; } }
|
||||
public String _Notes { get { return Cols._Notes.Value; } set { Cols._Notes.Value = value; } }
|
||||
public Int16 _Flags { get { return Cols._Flags.Value; } set { Cols._Flags.Value = value; } }
|
||||
public Int16? _Flags { get { return Cols._Flags.Value; } set { Cols._Flags.Value = value; } }
|
||||
public String _Status { get { return Cols._Status.Value; } set { Cols._Status.Value = value; } }
|
||||
public DateTime _CreateOn { get { return Cols._CreateOn.Value; } set { Cols._CreateOn.Value = value; } }
|
||||
public Int32 _CreateBy { get { return Cols._CreateBy.Value; } set { Cols._CreateBy.Value = value; } }
|
||||
public DateTime? _CreateOn { get { return Cols._CreateOn.Value; } set { Cols._CreateOn.Value = value; } }
|
||||
public Int32? _CreateBy { get { return Cols._CreateBy.Value; } set { Cols._CreateBy.Value = value; } }
|
||||
public String _CreateHost { get { return Cols._CreateHost.Value; } set { Cols._CreateHost.Value = value; } }
|
||||
public DateTime _UpdateOn { get { return Cols._UpdateOn.Value; } set { Cols._UpdateOn.Value = value; } }
|
||||
public Int32 _UpdateBy { get { return Cols._UpdateBy.Value; } set { Cols._UpdateBy.Value = value; } }
|
||||
public DateTime? _UpdateOn { get { return Cols._UpdateOn.Value; } set { Cols._UpdateOn.Value = value; } }
|
||||
public Int32? _UpdateBy { get { return Cols._UpdateBy.Value; } set { Cols._UpdateBy.Value = value; } }
|
||||
public String _UpdateHost { get { return Cols._UpdateHost.Value; } set { Cols._UpdateHost.Value = value; } }
|
||||
// Existing columns - confirmed on database if table exists.
|
||||
public List<String> ExistingColumnNames { get { return GetExistingColumnNames(Fields); } }
|
||||
public List<String> ExistingColumnNamesNonId { get { return GetExistingColumnNames(FieldsNonId); } }
|
||||
public List<String> UpdatableColumns { get { return ExistingColumnNamesNonId.Where(item => !fieldsPrimary.ContainsCI(item) && !fieldsIgnoreOnUpdate.ContainsCI(item)).ToList(); } }
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// Population.
|
||||
@@ -142,20 +166,20 @@ namespace Sarand.BusinessMgr.Net.Standard.Dbas.Internal
|
||||
_CodeAlt1 = GetFieldString(dbDataReader, "CodeAlt1", _CodeAlt1);
|
||||
_CodeAlt2 = GetFieldString(dbDataReader, "CodeAlt2", _CodeAlt2);
|
||||
_Description = GetFieldString(dbDataReader, "Description", _Description);
|
||||
_RegionId = GetFieldInt32(dbDataReader, "RegionId", _RegionId);
|
||||
_EffectFrom = GetFieldDateTime(dbDataReader, "EffectFrom", _EffectFrom);
|
||||
_EffectTo = GetFieldDateTime(dbDataReader, "EffectTo", _EffectTo);
|
||||
_TaxRate = GetFieldDecimal(dbDataReader, "TaxRate", _TaxRate);
|
||||
_TaxRatePrev = GetFieldDecimal(dbDataReader, "TaxRatePrev", _TaxRatePrev);
|
||||
_TaxCodeIdLink = GetFieldInt32(dbDataReader, "TaxCodeIdLink", _TaxCodeIdLink);
|
||||
_RegionId = GetFieldInt32Nullable(dbDataReader, "RegionId", _RegionId);
|
||||
_EffectFrom = GetFieldDateTimeNullable(dbDataReader, "EffectFrom", _EffectFrom);
|
||||
_EffectTo = GetFieldDateTimeNullable(dbDataReader, "EffectTo", _EffectTo);
|
||||
_TaxRate = GetFieldDecimalNullable(dbDataReader, "TaxRate", _TaxRate);
|
||||
_TaxRatePrev = GetFieldDecimalNullable(dbDataReader, "TaxRatePrev", _TaxRatePrev);
|
||||
_TaxCodeIdLink = GetFieldInt32Nullable(dbDataReader, "TaxCodeIdLink", _TaxCodeIdLink);
|
||||
_Notes = GetFieldString(dbDataReader, "Notes", _Notes);
|
||||
_Flags = GetFieldInt16(dbDataReader, "Flags", _Flags);
|
||||
_Flags = GetFieldInt16Nullable(dbDataReader, "Flags", _Flags);
|
||||
_Status = GetFieldString(dbDataReader, "Status", _Status);
|
||||
_CreateOn = GetFieldDateTime(dbDataReader, "CreateOn", _CreateOn);
|
||||
_CreateBy = GetFieldInt32(dbDataReader, "CreateBy", _CreateBy);
|
||||
_CreateOn = GetFieldDateTimeNullable(dbDataReader, "CreateOn", _CreateOn);
|
||||
_CreateBy = GetFieldInt32Nullable(dbDataReader, "CreateBy", _CreateBy);
|
||||
_CreateHost = GetFieldString(dbDataReader, "CreateHost", _CreateHost);
|
||||
_UpdateOn = GetFieldDateTime(dbDataReader, "UpdateOn", _UpdateOn);
|
||||
_UpdateBy = GetFieldInt32(dbDataReader, "UpdateBy", _UpdateBy);
|
||||
_UpdateOn = GetFieldDateTimeNullable(dbDataReader, "UpdateOn", _UpdateOn);
|
||||
_UpdateBy = GetFieldInt32Nullable(dbDataReader, "UpdateBy", _UpdateBy);
|
||||
_UpdateHost = GetFieldString(dbDataReader, "UpdateHost", _UpdateHost);
|
||||
}
|
||||
|
||||
@@ -207,10 +231,15 @@ namespace Sarand.BusinessMgr.Net.Standard.Dbas.Internal
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// Update command.
|
||||
public override bool ExecuteUpdateCommand (DbCommand dbCommand)
|
||||
public override bool ExecuteUpdateCommand (DbCommand dbCommand, List<String> columnsToUpdate = null)
|
||||
{
|
||||
// Columns to update.
|
||||
List<String> columnNames = ExistingColumnNamesNonId.Where(item => !fieldsPrimary.ContainsCI(item) && !fieldsIgnoreOnUpdate.ContainsCI(item)).ToList();
|
||||
List<String> columnNames = (columnsToUpdate?.Any() ?? false ? columnsToUpdate : UpdatableColumns).Where(col => UpdatableColumns.ContainsCI(col)).ToList();
|
||||
if (!columnNames.Any())
|
||||
{
|
||||
SaLogger.Warn($"{SysUtil.Fn} No columns to update. [{GetType().Name}]");
|
||||
return false;
|
||||
}
|
||||
// Construct query.
|
||||
String query = "UPDATE " + TableNameFmt + " SET ";
|
||||
if (dbCommand is SqlCommand)
|
||||
|
||||
Reference in New Issue
Block a user