From 128bd786f8a64eba95b6fb54e5c2a5668eb5d992 Mon Sep 17 00:00:00 2001 From: John Cardinal Date: Thu, 13 Feb 2020 23:44:39 +0000 Subject: [PATCH] --- server/AyaNova/DataList/DataListFetcher.cs | 11 +++++------ .../DataList/DataListSqlSelectBuilder.cs | 19 +++---------------- 2 files changed, 8 insertions(+), 22 deletions(-) diff --git a/server/AyaNova/DataList/DataListFetcher.cs b/server/AyaNova/DataList/DataListFetcher.cs index a0cc3269..b64e6f65 100644 --- a/server/AyaNova/DataList/DataListFetcher.cs +++ b/server/AyaNova/DataList/DataListFetcher.cs @@ -34,13 +34,12 @@ namespace AyaNova.DataList var ListViewArray = JArray.Parse(listOptions.ListView); - - - List templateFieldList = DataList.GetFieldListFromListView(ListViewArray); + //Get the field key names in a list from the listview + List ListViewFieldList = DataList.GetFieldListFromListView(ListViewArray); //BUILD THE QUERY //SELECT FRAGMENT COLUMNS FROM TEMPLATE - var qSelectColumns = DataListSqlSelectBuilder.Build(DataList.FieldDefinitions, ListViewArray); + var qSelectColumns = DataListSqlSelectBuilder.Build(DataList.FieldDefinitions, ListViewFieldList); //FROM CLAUSE var qFrom = DataList.SQLFrom; @@ -68,7 +67,7 @@ namespace AyaNova.DataList qTotalRecordsQuery = $"SELECT COUNT(*) {qFrom} {qWhere}".Replace(" ", " "); //RETURN OBJECTS - int returnRowColumnCount = templateFieldList.Count() + 1;//Templates don't have the DF column in them but we need it and it's in the query so plus one + int returnRowColumnCount = ListViewFieldList.Count() + 1;//Templates don't have the DF column in them but we need it and it's in the query so plus one List> rows = new List>(); long totalRecordCount = 0; @@ -102,7 +101,7 @@ namespace AyaNova.DataList int nCurrentColumnPointer = 1;//start at 1 //INSERT REMAINING FIELDS FROM TEMPLATE INTO THE RETURN ROWS LIST - foreach (string TemplateField in templateFieldList) + foreach (string TemplateField in ListViewFieldList) { //get the AyaObjectFieldDefinition AyaDataListFieldDefinition f = DataList.FieldDefinitions.FirstOrDefault(x => x.FieldKey == TemplateField); diff --git a/server/AyaNova/DataList/DataListSqlSelectBuilder.cs b/server/AyaNova/DataList/DataListSqlSelectBuilder.cs index bbd5335f..5228edd0 100644 --- a/server/AyaNova/DataList/DataListSqlSelectBuilder.cs +++ b/server/AyaNova/DataList/DataListSqlSelectBuilder.cs @@ -12,24 +12,11 @@ namespace AyaNova.DataList internal static class DataListSqlSelectBuilder { - //Build the SELECT portion of a list query based on the template, mini or full and the object key in question - internal static string Build(List objectFieldsList, JArray listViewArray) + //Build the SELECT portion of a list query based on the ListView fields + internal static string Build(List objectFieldsList, List listViewFieldList) { - - //convert to strings array (https://stackoverflow.com/a/33836599/8939) - // [{key:"COLUMN UNIQUE KEY ID",sort:"-" or "+",filter:{any:true/false,items:[{FILTER OBJECT SEE BELOW}]} }, {key:"second column unique key"},{...etc...}] - string[] templateFieldList; - if (mini!=null && mini==true) - { - templateFieldList = ((JArray)jtemplate["mini"]).ToObject(); - } - else - { - templateFieldList = ((JArray)jtemplate["full"]).ToObject(); - } - StringBuilder sb = new StringBuilder(); sb.Append("SELECT "); @@ -50,7 +37,7 @@ namespace AyaNova.DataList sb.Append(" AS df"); - foreach (string ColumnName in templateFieldList) + foreach (string ColumnName in listViewFieldList) { AyaDataListFieldDefinition o = objectFieldsList.FirstOrDefault(x => x.FieldKey == ColumnName); #if (DEBUG)