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,28 +25,28 @@ namespace Sarand.BusinessMgr.Net.Standard.Dbas.Internal
|
||||
public ColumnDataString _Model { get; } = new ColumnDataString("Model");
|
||||
public ColumnDataString _Derivative { get; } = new ColumnDataString("Derivative");
|
||||
public ColumnDataString _DescBrief { get; } = new ColumnDataString("DescBrief");
|
||||
public ColumnDataInt16 _VehicleType { get; } = new ColumnDataInt16("VehicleType");
|
||||
public ColumnDataInt16Nullable _VehicleType { get; } = new ColumnDataInt16Nullable("VehicleType");
|
||||
public ColumnDataString _VehicleCategoryCode { get; } = new ColumnDataString("VehicleCategoryCode");
|
||||
public ColumnDataInt16 _FuelType { get; } = new ColumnDataInt16("FuelType");
|
||||
public ColumnDataInt16 _OdometerUnits { get; } = new ColumnDataInt16("OdometerUnits");
|
||||
public ColumnDataInt16 _Seats { get; } = new ColumnDataInt16("Seats");
|
||||
public ColumnDataDecimal _Weight { get; } = new ColumnDataDecimal("Weight");
|
||||
public ColumnDataInt16Nullable _FuelType { get; } = new ColumnDataInt16Nullable("FuelType");
|
||||
public ColumnDataInt16Nullable _OdometerUnits { get; } = new ColumnDataInt16Nullable("OdometerUnits");
|
||||
public ColumnDataInt16Nullable _Seats { get; } = new ColumnDataInt16Nullable("Seats");
|
||||
public ColumnDataDecimalNullable _Weight { get; } = new ColumnDataDecimalNullable("Weight");
|
||||
public ColumnDataString _InsuranceCode { get; } = new ColumnDataString("InsuranceCode");
|
||||
public ColumnDataInt32 _FirstServiceOdo { get; } = new ColumnDataInt32("FirstServiceOdo");
|
||||
public ColumnDataInt32 _ServiceOdo { get; } = new ColumnDataInt32("ServiceOdo");
|
||||
public ColumnDataInt16 _ServiceWeeks { get; } = new ColumnDataInt16("ServiceWeeks");
|
||||
public ColumnDataDecimal _AmountRentalCost { get; } = new ColumnDataDecimal("AmountRentalCost");
|
||||
public ColumnDataInt32 _UomIdRentalCost { get; } = new ColumnDataInt32("UomIdRentalCost");
|
||||
public ColumnDataDecimal _AmountRentalPrice { get; } = new ColumnDataDecimal("AmountRentalPrice");
|
||||
public ColumnDataInt32 _UomIdRentalPrice { get; } = new ColumnDataInt32("UomIdRentalPrice");
|
||||
public ColumnDataInt32Nullable _FirstServiceOdo { get; } = new ColumnDataInt32Nullable("FirstServiceOdo");
|
||||
public ColumnDataInt32Nullable _ServiceOdo { get; } = new ColumnDataInt32Nullable("ServiceOdo");
|
||||
public ColumnDataInt16Nullable _ServiceWeeks { get; } = new ColumnDataInt16Nullable("ServiceWeeks");
|
||||
public ColumnDataDecimalNullable _AmountRentalCost { get; } = new ColumnDataDecimalNullable("AmountRentalCost");
|
||||
public ColumnDataInt32Nullable _UomIdRentalCost { get; } = new ColumnDataInt32Nullable("UomIdRentalCost");
|
||||
public ColumnDataDecimalNullable _AmountRentalPrice { get; } = new ColumnDataDecimalNullable("AmountRentalPrice");
|
||||
public ColumnDataInt32Nullable _UomIdRentalPrice { get; } = new ColumnDataInt32Nullable("UomIdRentalPrice");
|
||||
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");
|
||||
}
|
||||
|
||||
@@ -89,6 +90,36 @@ namespace Sarand.BusinessMgr.Net.Standard.Dbas.Internal
|
||||
{
|
||||
"Id",
|
||||
};
|
||||
protected static List<String> fieldsNullable { get; } = new List<String>()
|
||||
{
|
||||
"MakeCode",
|
||||
"Model",
|
||||
"Derivative",
|
||||
"DescBrief",
|
||||
"VehicleType",
|
||||
"VehicleCategoryCode",
|
||||
"FuelType",
|
||||
"OdometerUnits",
|
||||
"Seats",
|
||||
"Weight",
|
||||
"InsuranceCode",
|
||||
"FirstServiceOdo",
|
||||
"ServiceOdo",
|
||||
"ServiceWeeks",
|
||||
"AmountRentalCost",
|
||||
"UomIdRentalCost",
|
||||
"AmountRentalPrice",
|
||||
"UomIdRentalPrice",
|
||||
"Notes",
|
||||
"Flags",
|
||||
"Status",
|
||||
"CreateOn",
|
||||
"CreateBy",
|
||||
"CreateHost",
|
||||
"UpdateOn",
|
||||
"UpdateBy",
|
||||
"UpdateHost",
|
||||
};
|
||||
protected static List<String> fieldsIgnoreOnUpdate { get; } = new List<String>()
|
||||
{
|
||||
"CreateOn",
|
||||
@@ -117,32 +148,33 @@ namespace Sarand.BusinessMgr.Net.Standard.Dbas.Internal
|
||||
public String _Model { get { return Cols._Model.Value; } set { Cols._Model.Value = value; } }
|
||||
public String _Derivative { get { return Cols._Derivative.Value; } set { Cols._Derivative.Value = value; } }
|
||||
public String _DescBrief { get { return Cols._DescBrief.Value; } set { Cols._DescBrief.Value = value; } }
|
||||
public Int16 _VehicleType { get { return Cols._VehicleType.Value; } set { Cols._VehicleType.Value = value; } }
|
||||
public Int16? _VehicleType { get { return Cols._VehicleType.Value; } set { Cols._VehicleType.Value = value; } }
|
||||
public String _VehicleCategoryCode { get { return Cols._VehicleCategoryCode.Value; } set { Cols._VehicleCategoryCode.Value = value; } }
|
||||
public Int16 _FuelType { get { return Cols._FuelType.Value; } set { Cols._FuelType.Value = value; } }
|
||||
public Int16 _OdometerUnits { get { return Cols._OdometerUnits.Value; } set { Cols._OdometerUnits.Value = value; } }
|
||||
public Int16 _Seats { get { return Cols._Seats.Value; } set { Cols._Seats.Value = value; } }
|
||||
public Decimal _Weight { get { return Cols._Weight.Value; } set { Cols._Weight.Value = value; } }
|
||||
public Int16? _FuelType { get { return Cols._FuelType.Value; } set { Cols._FuelType.Value = value; } }
|
||||
public Int16? _OdometerUnits { get { return Cols._OdometerUnits.Value; } set { Cols._OdometerUnits.Value = value; } }
|
||||
public Int16? _Seats { get { return Cols._Seats.Value; } set { Cols._Seats.Value = value; } }
|
||||
public Decimal? _Weight { get { return Cols._Weight.Value; } set { Cols._Weight.Value = value; } }
|
||||
public String _InsuranceCode { get { return Cols._InsuranceCode.Value; } set { Cols._InsuranceCode.Value = value; } }
|
||||
public Int32 _FirstServiceOdo { get { return Cols._FirstServiceOdo.Value; } set { Cols._FirstServiceOdo.Value = value; } }
|
||||
public Int32 _ServiceOdo { get { return Cols._ServiceOdo.Value; } set { Cols._ServiceOdo.Value = value; } }
|
||||
public Int16 _ServiceWeeks { get { return Cols._ServiceWeeks.Value; } set { Cols._ServiceWeeks.Value = value; } }
|
||||
public Decimal _AmountRentalCost { get { return Cols._AmountRentalCost.Value; } set { Cols._AmountRentalCost.Value = value; } }
|
||||
public Int32 _UomIdRentalCost { get { return Cols._UomIdRentalCost.Value; } set { Cols._UomIdRentalCost.Value = value; } }
|
||||
public Decimal _AmountRentalPrice { get { return Cols._AmountRentalPrice.Value; } set { Cols._AmountRentalPrice.Value = value; } }
|
||||
public Int32 _UomIdRentalPrice { get { return Cols._UomIdRentalPrice.Value; } set { Cols._UomIdRentalPrice.Value = value; } }
|
||||
public Int32? _FirstServiceOdo { get { return Cols._FirstServiceOdo.Value; } set { Cols._FirstServiceOdo.Value = value; } }
|
||||
public Int32? _ServiceOdo { get { return Cols._ServiceOdo.Value; } set { Cols._ServiceOdo.Value = value; } }
|
||||
public Int16? _ServiceWeeks { get { return Cols._ServiceWeeks.Value; } set { Cols._ServiceWeeks.Value = value; } }
|
||||
public Decimal? _AmountRentalCost { get { return Cols._AmountRentalCost.Value; } set { Cols._AmountRentalCost.Value = value; } }
|
||||
public Int32? _UomIdRentalCost { get { return Cols._UomIdRentalCost.Value; } set { Cols._UomIdRentalCost.Value = value; } }
|
||||
public Decimal? _AmountRentalPrice { get { return Cols._AmountRentalPrice.Value; } set { Cols._AmountRentalPrice.Value = value; } }
|
||||
public Int32? _UomIdRentalPrice { get { return Cols._UomIdRentalPrice.Value; } set { Cols._UomIdRentalPrice.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.
|
||||
@@ -166,28 +198,28 @@ namespace Sarand.BusinessMgr.Net.Standard.Dbas.Internal
|
||||
_Model = GetFieldString(dbDataReader, "Model", _Model);
|
||||
_Derivative = GetFieldString(dbDataReader, "Derivative", _Derivative);
|
||||
_DescBrief = GetFieldString(dbDataReader, "DescBrief", _DescBrief);
|
||||
_VehicleType = GetFieldInt16(dbDataReader, "VehicleType", _VehicleType);
|
||||
_VehicleType = GetFieldInt16Nullable(dbDataReader, "VehicleType", _VehicleType);
|
||||
_VehicleCategoryCode = GetFieldString(dbDataReader, "VehicleCategoryCode", _VehicleCategoryCode);
|
||||
_FuelType = GetFieldInt16(dbDataReader, "FuelType", _FuelType);
|
||||
_OdometerUnits = GetFieldInt16(dbDataReader, "OdometerUnits", _OdometerUnits);
|
||||
_Seats = GetFieldInt16(dbDataReader, "Seats", _Seats);
|
||||
_Weight = GetFieldDecimal(dbDataReader, "Weight", _Weight);
|
||||
_FuelType = GetFieldInt16Nullable(dbDataReader, "FuelType", _FuelType);
|
||||
_OdometerUnits = GetFieldInt16Nullable(dbDataReader, "OdometerUnits", _OdometerUnits);
|
||||
_Seats = GetFieldInt16Nullable(dbDataReader, "Seats", _Seats);
|
||||
_Weight = GetFieldDecimalNullable(dbDataReader, "Weight", _Weight);
|
||||
_InsuranceCode = GetFieldString(dbDataReader, "InsuranceCode", _InsuranceCode);
|
||||
_FirstServiceOdo = GetFieldInt32(dbDataReader, "FirstServiceOdo", _FirstServiceOdo);
|
||||
_ServiceOdo = GetFieldInt32(dbDataReader, "ServiceOdo", _ServiceOdo);
|
||||
_ServiceWeeks = GetFieldInt16(dbDataReader, "ServiceWeeks", _ServiceWeeks);
|
||||
_AmountRentalCost = GetFieldDecimal(dbDataReader, "AmountRentalCost", _AmountRentalCost);
|
||||
_UomIdRentalCost = GetFieldInt32(dbDataReader, "UomIdRentalCost", _UomIdRentalCost);
|
||||
_AmountRentalPrice = GetFieldDecimal(dbDataReader, "AmountRentalPrice", _AmountRentalPrice);
|
||||
_UomIdRentalPrice = GetFieldInt32(dbDataReader, "UomIdRentalPrice", _UomIdRentalPrice);
|
||||
_FirstServiceOdo = GetFieldInt32Nullable(dbDataReader, "FirstServiceOdo", _FirstServiceOdo);
|
||||
_ServiceOdo = GetFieldInt32Nullable(dbDataReader, "ServiceOdo", _ServiceOdo);
|
||||
_ServiceWeeks = GetFieldInt16Nullable(dbDataReader, "ServiceWeeks", _ServiceWeeks);
|
||||
_AmountRentalCost = GetFieldDecimalNullable(dbDataReader, "AmountRentalCost", _AmountRentalCost);
|
||||
_UomIdRentalCost = GetFieldInt32Nullable(dbDataReader, "UomIdRentalCost", _UomIdRentalCost);
|
||||
_AmountRentalPrice = GetFieldDecimalNullable(dbDataReader, "AmountRentalPrice", _AmountRentalPrice);
|
||||
_UomIdRentalPrice = GetFieldInt32Nullable(dbDataReader, "UomIdRentalPrice", _UomIdRentalPrice);
|
||||
_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);
|
||||
}
|
||||
|
||||
@@ -247,10 +279,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