This commit is contained in:
2020-02-13 23:44:39 +00:00
parent b79c98cc9d
commit 128bd786f8
2 changed files with 8 additions and 22 deletions

View File

@@ -34,13 +34,12 @@ namespace AyaNova.DataList
var ListViewArray = JArray.Parse(listOptions.ListView);
List<string> templateFieldList = DataList.GetFieldListFromListView(ListViewArray);
//Get the field key names in a list from the listview
List<string> 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<List<AyaFieldData>> rows = new List<List<AyaFieldData>>();
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);

View File

@@ -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<AyaDataListFieldDefinition> objectFieldsList, JArray listViewArray)
//Build the SELECT portion of a list query based on the ListView fields
internal static string Build(List<AyaDataListFieldDefinition> objectFieldsList, List<string> 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<string[]>();
}
else
{
templateFieldList = ((JArray)jtemplate["full"]).ToObject<string[]>();
}
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)