Saxonite 1.2.11.14
This commit is contained in:
@@ -77,7 +77,7 @@ namespace Sarand.Net.Standard.Dbas.Base
|
||||
public class TableClassConfig
|
||||
{
|
||||
/// <summary>Using namespaces for table classes.</summary>
|
||||
public HashSet<String> Usings { get; } = new HashSet<String>() { "Sarand.Net.Standard.Base.Core", "Sarand.Net.Standard.Base.Dbas" };
|
||||
public HashSet<String> Usings { get; } = new HashSet<String>() { "Sarand.Net.Standard.Base.App", "Sarand.Net.Standard.Base.Core", "Sarand.Net.Standard.Base.Dbas" };
|
||||
public String Namespace_BaseClass { get; set; } = "Sarand.Net.Standard.Dbas.Data";
|
||||
public String Namespace { get; set; } = "Sarand.Application.Dbas";
|
||||
public String BaseClass { get; set; } = "DbDataItem";
|
||||
@@ -672,6 +672,7 @@ namespace Sarand.Net.Standard.Dbas.Base
|
||||
file.WriteLine(tab2 + "// Existing columns - confirmed on database if table exists.");
|
||||
file.WriteLine(tab2 + "public List<String> ExistingColumnNames { get { return GetExistingColumnNames(Fields); } }");
|
||||
file.WriteLine(tab2 + "public List<String> ExistingColumnNamesNonId { get { return GetExistingColumnNames(FieldsNonId); } }");
|
||||
file.WriteLine(tab2 + "public List<String> UpdatableColumns { get { return ExistingColumnNamesNonId.Where(item => !fieldsPrimary.ContainsCI(item) && !fieldsIgnoreOnUpdate.ContainsCI(item)).ToList(); } }");
|
||||
|
||||
//-----------------------------------------------------------
|
||||
// Population.
|
||||
@@ -787,7 +788,7 @@ namespace Sarand.Net.Standard.Dbas.Base
|
||||
// Construct update command.
|
||||
file.WriteLine(crlf + tab2 + "//-------------------------------------------------------------------");
|
||||
file.WriteLine(tab2 + "// Update command.");
|
||||
file.WriteLine(tab2 + "public override bool ExecuteUpdateCommand (DbCommand dbCommand)");
|
||||
file.WriteLine(tab2 + "public override bool ExecuteUpdateCommand (DbCommand dbCommand, List<String> columnsToUpdate = null)");
|
||||
file.WriteLine(tab2 + "{");
|
||||
if (!String.IsNullOrEmpty(identityColumnName))
|
||||
{
|
||||
@@ -795,7 +796,12 @@ namespace Sarand.Net.Standard.Dbas.Base
|
||||
file.WriteLine(tab3 + "if (_" + identityColumnName + " == 0) throw new Exception(\"Invalid for Update - item has an invalid Id\"); ");
|
||||
}
|
||||
file.WriteLine(tab3 + "// Columns to update.");
|
||||
file.WriteLine(tab3 + "List<String> columnNames = ExistingColumnNamesNonId.Where(item => !fieldsPrimary.ContainsCI(item) && !fieldsIgnoreOnUpdate.ContainsCI(item)).ToList();");
|
||||
file.WriteLine(tab3 + "List<String> columnNames = (columnsToUpdate?.Any() ?? false ? columnsToUpdate : UpdatableColumns).Where(col => UpdatableColumns.ContainsCI(col)).ToList();");
|
||||
file.WriteLine(tab3 + "if (!columnNames.Any())");
|
||||
file.WriteLine(tab3 + "{");
|
||||
file.WriteLine(tab4 + "SaLogger.Warn($\"{SysUtil.Fn} No columns to update. [{GetType().Name}]\");");
|
||||
file.WriteLine(tab4 + "return false;");
|
||||
file.WriteLine(tab3 + "}");
|
||||
file.WriteLine(tab3 + "// Construct query.");
|
||||
file.WriteLine(tab3 + "String query = \"UPDATE \" + TableNameFmt + \" SET \";");
|
||||
List<String> columnsValuesToUpdate = new List<String>();
|
||||
|
||||
@@ -590,7 +590,14 @@ namespace Sarand.Net.Standard.Dbas.Data
|
||||
//-------------------------------------------------------------------
|
||||
// Database updates via ODBC Command.
|
||||
public abstract bool ExecuteInsertCommand(DbCommand dbCommand);
|
||||
public abstract bool ExecuteUpdateCommand(DbCommand dbCommand);
|
||||
public virtual bool ExecuteUpdateCommand(DbCommand dbCommand)
|
||||
{
|
||||
return ExecuteUpdateCommand(dbCommand, null);
|
||||
}
|
||||
public virtual bool ExecuteUpdateCommand(DbCommand dbCommand, List<String> columns = null)
|
||||
{
|
||||
throw new NotImplementedException($"ExecuteUpdateCommand(dbCmd,cols) not overridden. [{GetType().Name}]");
|
||||
}
|
||||
//public abstract bool ExecuteDeleteCommand (DbCommand dbCommand);
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
|
||||
@@ -190,7 +190,7 @@ namespace Sarand.Net.Standard.Dbas.Data
|
||||
}
|
||||
catch (Exception exc)
|
||||
{
|
||||
SaLogger.Error(SysUtil.Fn + " " + ExceptionUtil.GetLogMessage(exc) + "\n\tQuery: " + query, true);
|
||||
SaLogger.Error($"{SysUtil.Fn} {ExceptionUtil.GetLogMessage(exc)}\nQuery:\n\t{String.Join("\n\t", query.ReplaceAll("\n\r", "\n").Split("\n"))}", true);
|
||||
SetErrorState(exc.Message);
|
||||
}
|
||||
return new DbDataTable(dataTable);
|
||||
@@ -213,7 +213,7 @@ namespace Sarand.Net.Standard.Dbas.Data
|
||||
}
|
||||
catch (Exception exc)
|
||||
{
|
||||
SaLogger.Error(SysUtil.Fn + " " + ExceptionUtil.GetLogMessage(exc) + "\n\tQuery: " + query, true);
|
||||
SaLogger.Error($"{SysUtil.Fn} {ExceptionUtil.GetLogMessage(exc)}\nQuery:\n\t{String.Join("\n\t", query.ReplaceAll("\n\r", "\n").Split("\n"))}", true);
|
||||
SetErrorState(exc.Message);
|
||||
}
|
||||
}
|
||||
@@ -241,7 +241,7 @@ namespace Sarand.Net.Standard.Dbas.Data
|
||||
}
|
||||
catch (Exception exc)
|
||||
{
|
||||
SaLogger.Error(SysUtil.Fn + " " + ExceptionUtil.GetLogMessage(exc) + "\n\tQuery: " + query, true);
|
||||
SaLogger.Error($"{SysUtil.Fn} {ExceptionUtil.GetLogMessage(exc)}\nQuery:\n\t{String.Join("\n\t", query.ReplaceAll("\n\r", "\n").Split("\n"))}", true);
|
||||
SetErrorState(exc.Message);
|
||||
}
|
||||
}
|
||||
@@ -270,7 +270,7 @@ namespace Sarand.Net.Standard.Dbas.Data
|
||||
}
|
||||
catch (Exception exc)
|
||||
{
|
||||
SaLogger.Error(SysUtil.Fn + " " + ExceptionUtil.GetLogMessage(exc) + "\n\tQuery: " + query, true);
|
||||
SaLogger.Error($"{SysUtil.Fn} {ExceptionUtil.GetLogMessage(exc)}\nQuery:\n\t{String.Join("\n\t", query.ReplaceAll("\n\r", "\n").Split("\n"))}", true);
|
||||
SetErrorState(exc.Message);
|
||||
}
|
||||
}
|
||||
@@ -297,7 +297,7 @@ namespace Sarand.Net.Standard.Dbas.Data
|
||||
}
|
||||
catch (Exception exc)
|
||||
{
|
||||
SaLogger.Error(SysUtil.Fn + " " + ExceptionUtil.GetLogMessage(exc) + "\n\tQuery: " + query, true);
|
||||
SaLogger.Error($"{SysUtil.Fn} {ExceptionUtil.GetLogMessage(exc)}\nQuery:\n\t{String.Join("\n\t", query.ReplaceAll("\n\r", "\n").Split("\n"))}", true);
|
||||
SetErrorState(exc.Message);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user