Migrated projects to dotnet8

migrated all projects over to .net8
incomplete feature for gui shipments
This commit is contained in:
Bobbie Hodgetts
2024-11-20 16:37:42 +00:00
committed by GitHub
parent 270eebca9a
commit 7a12b49b44
78 changed files with 4127 additions and 1339 deletions

View File

@@ -64,6 +64,89 @@ namespace bnhtrade.Core.Data.Database
}
}
/// <summary>
/// Append an 'Like' statement (with AND between each like string) and parameter list to the class properties
/// </summary>
/// <param name="columnReference">Name of the column to used to for the condition statement</param>
/// <param name="phraseList">List of phrases to test in condition statement</param>
/// <param name="wherePrefix">Optional prefix that gets added to the sql string result</param>
public void LikeAnd(string columnReference, List<string> phraseList, string wherePrefix = null)
{
Like(columnReference, phraseList, true, wherePrefix);
}
/// <summary>
/// Append an 'Like' statement (with OR between each like string) and parameter list to the class properties
/// </summary>
/// <param name="columnReference">Name of the column to used to for the condition statement</param>
/// <param name="phraseList">List of phrases to test in condition statement</param>
/// <param name="wherePrefix">Optional prefix that gets added to the sql string result</param>
public void LikeOr(string columnReference, List<string> phraseList, string wherePrefix = null)
{
Like(columnReference, phraseList, false, wherePrefix);
}
private void Like(string columnReference, List<string> phraseList, bool isAnd, string wherePrefix = null)
{
if (phraseList == null || !phraseList.Any())
{
return;
}
// ensure no values are repeated
var distinctList = phraseList.ToList();
// clean the list
for (int i = 0; i < distinctList.Count; i++)
{
if (string.IsNullOrEmpty(distinctList[i]))
{
distinctList.RemoveAt(i);
i--;
}
}
// check again
if (distinctList == null || !distinctList.Any())
{
return;
}
string sqlWhere = @"
";
if (wherePrefix != null)
{
sqlWhere += wherePrefix;
}
int listCount = distinctList.Count();
for (int i = 0; i < listCount; i++, parameterCount++)
{
if (i > 0)
{
if (isAnd)
{
sqlWhere += " AND ";
}
else
{
sqlWhere += " OR ";
}
}
sqlWhere += " ( " + columnReference + " LIKE '%' + ";
string param = "@parameter" + parameterCount;
sqlWhere += param;
ParameterList.Add(param, distinctList[i]);
sqlWhere += " + '%' ) ";
}
SqlWhereString = SqlWhereString + sqlWhere;
}
/// <summary>
/// Append an 'In' statement and parameter list to the class properties
/// </summary>
@@ -126,5 +209,26 @@ namespace bnhtrade.Core.Data.Database
In(columnReference, stringList, wherePrefix);
}
/// <summary>
/// Append an 'In' statement and parameter list to the class properties
/// </summary>
/// <param name="columnReference">Name of the column to used to for the condition statement</param>
/// <param name="orValueList">List of values to test in condition statement</param>
/// <param name="wherePrefix">Optional prefix that gets added to the sql string result</param>
public void In(string columnReference, List<uint> orValueList, string wherePrefix = null)
{
var stringList = new List<string>();
if (orValueList != null || !orValueList.Any())
{
foreach (uint value in orValueList)
{
stringList.Add(value.ToString());
}
}
In(columnReference, stringList, wherePrefix);
}
}
}