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
|
||||
{
|
||||
@@ -21,22 +22,22 @@ namespace Sarand.BusinessMgr.Net.Standard.Dbas.Internal
|
||||
{
|
||||
public ColumnDataInt32 _Id { get; } = new ColumnDataInt32("Id");
|
||||
public ColumnDataInt32 _AffIdOwner { get; } = new ColumnDataInt32("AffIdOwner");
|
||||
public ColumnDataInt16 _Category { get; } = new ColumnDataInt16("Category");
|
||||
public ColumnDataInt16Nullable _Category { get; } = new ColumnDataInt16Nullable("Category");
|
||||
public ColumnDataString _Type { get; } = new ColumnDataString("Type");
|
||||
public ColumnDataString _Reference { get; } = new ColumnDataString("Reference");
|
||||
public ColumnDataString _DescBrief { get; } = new ColumnDataString("DescBrief");
|
||||
public ColumnDataString _TagId { get; } = new ColumnDataString("TagId");
|
||||
public ColumnDataInt32 _AssIdSupplier { get; } = new ColumnDataInt32("AssIdSupplier");
|
||||
public ColumnDataInt32 _AssIdCustomer { get; } = new ColumnDataInt32("AssIdCustomer");
|
||||
public ColumnDataDateTime _Expected { get; } = new ColumnDataDateTime("Expected");
|
||||
public ColumnDataInt32Nullable _AssIdSupplier { get; } = new ColumnDataInt32Nullable("AssIdSupplier");
|
||||
public ColumnDataInt32Nullable _AssIdCustomer { get; } = new ColumnDataInt32Nullable("AssIdCustomer");
|
||||
public ColumnDataDateTimeNullable _Expected { get; } = new ColumnDataDateTimeNullable("Expected");
|
||||
public ColumnDataString _Notes { get; } = new ColumnDataString("Notes");
|
||||
public ColumnDataInt16 _Flags { get; } = new ColumnDataInt16("Flags");
|
||||
public ColumnDataString _Status { get; } = new ColumnDataString("Status");
|
||||
public ColumnDataDateTime _CreateOn { get; } = new ColumnDataDateTime("CreateOn");
|
||||
public ColumnDataInt32 _CreateBy { get; } = new ColumnDataInt32("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");
|
||||
}
|
||||
|
||||
@@ -71,6 +72,20 @@ namespace Sarand.BusinessMgr.Net.Standard.Dbas.Internal
|
||||
{
|
||||
"Id",
|
||||
};
|
||||
protected static List<String> fieldsNullable { get; } = new List<String>()
|
||||
{
|
||||
"Category",
|
||||
"DescBrief",
|
||||
"TagId",
|
||||
"AssIdSupplier",
|
||||
"AssIdCustomer",
|
||||
"Expected",
|
||||
"Notes",
|
||||
"CreateHost",
|
||||
"UpdateOn",
|
||||
"UpdateBy",
|
||||
"UpdateHost",
|
||||
};
|
||||
protected static List<String> fieldsIgnoreOnUpdate { get; } = new List<String>()
|
||||
{
|
||||
"CreateOn",
|
||||
@@ -96,26 +111,27 @@ namespace Sarand.BusinessMgr.Net.Standard.Dbas.Internal
|
||||
public ColumnsData Cols { get; } = new ColumnsData();
|
||||
public Int32 _Id { get { return Cols._Id.Value; } set { Cols._Id.Value = value; } }
|
||||
public Int32 _AffIdOwner { get { return Cols._AffIdOwner.Value; } set { Cols._AffIdOwner.Value = value; } }
|
||||
public Int16 _Category { get { return Cols._Category.Value; } set { Cols._Category.Value = value; } }
|
||||
public Int16? _Category { get { return Cols._Category.Value; } set { Cols._Category.Value = value; } }
|
||||
public String _Type { get { return Cols._Type.Value; } set { Cols._Type.Value = value; } }
|
||||
public String _Reference { get { return Cols._Reference.Value; } set { Cols._Reference.Value = value; } }
|
||||
public String _DescBrief { get { return Cols._DescBrief.Value; } set { Cols._DescBrief.Value = value; } }
|
||||
public String _TagId { get { return Cols._TagId.Value; } set { Cols._TagId.Value = value; } }
|
||||
public Int32 _AssIdSupplier { get { return Cols._AssIdSupplier.Value; } set { Cols._AssIdSupplier.Value = value; } }
|
||||
public Int32 _AssIdCustomer { get { return Cols._AssIdCustomer.Value; } set { Cols._AssIdCustomer.Value = value; } }
|
||||
public DateTime _Expected { get { return Cols._Expected.Value; } set { Cols._Expected.Value = value; } }
|
||||
public Int32? _AssIdSupplier { get { return Cols._AssIdSupplier.Value; } set { Cols._AssIdSupplier.Value = value; } }
|
||||
public Int32? _AssIdCustomer { get { return Cols._AssIdCustomer.Value; } set { Cols._AssIdCustomer.Value = value; } }
|
||||
public DateTime? _Expected { get { return Cols._Expected.Value; } set { Cols._Expected.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 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 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.
|
||||
@@ -136,22 +152,22 @@ namespace Sarand.BusinessMgr.Net.Standard.Dbas.Internal
|
||||
{
|
||||
_Id = GetFieldInt32(dbDataReader, "Id", _Id);
|
||||
_AffIdOwner = GetFieldInt32(dbDataReader, "AffIdOwner", _AffIdOwner);
|
||||
_Category = GetFieldInt16(dbDataReader, "Category", _Category);
|
||||
_Category = GetFieldInt16Nullable(dbDataReader, "Category", _Category);
|
||||
_Type = GetFieldString(dbDataReader, "Type", _Type);
|
||||
_Reference = GetFieldString(dbDataReader, "Reference", _Reference);
|
||||
_DescBrief = GetFieldString(dbDataReader, "DescBrief", _DescBrief);
|
||||
_TagId = GetFieldString(dbDataReader, "TagId", _TagId);
|
||||
_AssIdSupplier = GetFieldInt32(dbDataReader, "AssIdSupplier", _AssIdSupplier);
|
||||
_AssIdCustomer = GetFieldInt32(dbDataReader, "AssIdCustomer", _AssIdCustomer);
|
||||
_Expected = GetFieldDateTime(dbDataReader, "Expected", _Expected);
|
||||
_AssIdSupplier = GetFieldInt32Nullable(dbDataReader, "AssIdSupplier", _AssIdSupplier);
|
||||
_AssIdCustomer = GetFieldInt32Nullable(dbDataReader, "AssIdCustomer", _AssIdCustomer);
|
||||
_Expected = GetFieldDateTimeNullable(dbDataReader, "Expected", _Expected);
|
||||
_Notes = GetFieldString(dbDataReader, "Notes", _Notes);
|
||||
_Flags = GetFieldInt16(dbDataReader, "Flags", _Flags);
|
||||
_Status = GetFieldString(dbDataReader, "Status", _Status);
|
||||
_CreateOn = GetFieldDateTime(dbDataReader, "CreateOn", _CreateOn);
|
||||
_CreateBy = GetFieldInt32(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);
|
||||
}
|
||||
|
||||
@@ -202,10 +218,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