This commit is contained in:
@@ -44,7 +44,7 @@ namespace AyaNova.DataList
|
||||
|
||||
//BUILD THE QUERY
|
||||
//SELECT FRAGMENT COLUMNS FROM TEMPLATE
|
||||
var qSelectColumns = DataListSqlSelectBuilder.Build(DataList.FieldDefinitions, ListViewFieldList);
|
||||
var SelectBuild = DataListSqlSelectBuilder.Build(DataList.FieldDefinitions, ListViewFieldList);
|
||||
|
||||
//FROM CLAUSE
|
||||
var qFrom = DataList.SQLFrom;
|
||||
@@ -68,7 +68,7 @@ namespace AyaNova.DataList
|
||||
string qDataQuery = string.Empty;
|
||||
string qTotalRecordsQuery = string.Empty;
|
||||
|
||||
qDataQuery = $"{qSelectColumns} {qFrom} {qWhere} {qOrderBy} {qLimitOffset}".Replace(" ", " ");
|
||||
qDataQuery = $"{SelectBuild.Select} {qFrom} {qWhere} {qOrderBy} {qLimitOffset}".Replace(" ", " ");
|
||||
qTotalRecordsQuery = $"SELECT COUNT(*) {qFrom} {qWhere}".Replace(" ", " ");
|
||||
|
||||
//RETURN OBJECTS
|
||||
@@ -103,10 +103,10 @@ namespace AyaNova.DataList
|
||||
}
|
||||
|
||||
//GetOrdinal by name is flakey in npgsql so just going by field definition and ordinal numerically
|
||||
int nCurrentColumnPointer = 1;//start at 1
|
||||
// dr.GetOrdinal();
|
||||
// dr.GetName();
|
||||
//INSERT REMAINING FIELDS FROM TEMPLATE INTO THE RETURN ROWS LIST
|
||||
// int nCurrentColumnPointer = 1;//start at 1
|
||||
// dr.GetOrdinal();
|
||||
// dr.GetName();
|
||||
//INSERT REMAINING FIELDS FROM TEMPLATE INTO THE RETURN ROWS LIST
|
||||
foreach (string TemplateField in ListViewFieldList)
|
||||
{
|
||||
if (TemplateField == "df")
|
||||
@@ -115,7 +115,18 @@ namespace AyaNova.DataList
|
||||
AyaDataListFieldDefinition f = DataList.FieldDefinitions.FirstOrDefault(x => x.FieldKey == TemplateField);
|
||||
if (f.IsCustomField)
|
||||
{
|
||||
var v=dr;
|
||||
|
||||
AyaFieldData AyaField = new AyaFieldData();
|
||||
var cust = dr.GetString(SelectBuild.map[f.GetSqlValueColumnName()]);
|
||||
if (!string.IsNullOrWhiteSpace(cust))
|
||||
{
|
||||
JObject j = JObject.Parse(cust);
|
||||
//convert field name to cust name then get value
|
||||
var InternalCustomFieldName = AyaFormFieldDefinitions.TranslateLTCustomFieldToInternalCustomFieldName(TemplateField);
|
||||
AyaField.v = j[InternalCustomFieldName].Value<object>();
|
||||
row.Add(AyaField);
|
||||
}
|
||||
|
||||
/*
|
||||
TODO: Custom field handling
|
||||
GetName works just not with multipart identifiers
|
||||
@@ -123,7 +134,7 @@ namespace AyaNova.DataList
|
||||
I could map the ordinal when generating the Select fields so that I have a map to refer to here
|
||||
mapping in advance actually makes a lot of sense, then no more of this fragility of going by pointer index and hoping for the best
|
||||
it would just be premapped out.
|
||||
|
||||
|
||||
dr.GetOrdinal(f.SqlValueColumnName)
|
||||
'dr.GetOrdinal(f.SqlValueColumnName)' threw an exception of type 'System.IndexOutOfRangeException'
|
||||
f.SqlValueColumnName
|
||||
@@ -138,15 +149,16 @@ dr.GetOrdinal("customfields");
|
||||
else
|
||||
{
|
||||
AyaFieldData AyaField = new AyaFieldData();
|
||||
AyaField.v = dr.GetValue(nCurrentColumnPointer);
|
||||
nCurrentColumnPointer++;
|
||||
AyaField.v = dr.GetValue(SelectBuild.map[f.GetSqlValueColumnName()]);
|
||||
//nCurrentColumnPointer++;
|
||||
|
||||
if (f.SqlIdColumnName != null)//skip over df column id, it's not there
|
||||
{
|
||||
if (!await dr.IsDBNullAsync(nCurrentColumnPointer))
|
||||
AyaField.i = dr.GetInt64(nCurrentColumnPointer);
|
||||
var ordinal = SelectBuild.map[f.SqlIdColumnName];
|
||||
if (!await dr.IsDBNullAsync(ordinal))
|
||||
AyaField.i = dr.GetInt64(ordinal);
|
||||
|
||||
nCurrentColumnPointer++;
|
||||
//nCurrentColumnPointer++;
|
||||
}
|
||||
row.Add(AyaField);
|
||||
}
|
||||
|
||||
@@ -9,11 +9,16 @@ using Microsoft.Extensions.Logging;
|
||||
|
||||
namespace AyaNova.DataList
|
||||
{
|
||||
internal class SqlSelectBuilderResult
|
||||
{
|
||||
internal Dictionary<string, int> map { get; set; }
|
||||
internal string Select { get; set; }
|
||||
}
|
||||
internal static class DataListSqlSelectBuilder
|
||||
{
|
||||
|
||||
//Build the SELECT portion of a list query based on the ListView fields
|
||||
internal static string Build(List<AyaDataListFieldDefinition> objectFieldsList, List<string> listViewFieldList)
|
||||
internal static SqlSelectBuilderResult Build(List<AyaDataListFieldDefinition> objectFieldsList, List<string> listViewFieldList)
|
||||
{
|
||||
|
||||
|
||||
@@ -97,8 +102,9 @@ namespace AyaNova.DataList
|
||||
|
||||
}
|
||||
}
|
||||
TODO: return map and sb as composite object here
|
||||
return sb.ToString();
|
||||
return new SqlSelectBuilderResult() { map = map, Select = sb.ToString() };
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user