This commit is contained in:
@@ -34,13 +34,12 @@ namespace AyaNova.DataList
|
|||||||
var ListViewArray = JArray.Parse(listOptions.ListView);
|
var ListViewArray = JArray.Parse(listOptions.ListView);
|
||||||
|
|
||||||
|
|
||||||
|
//Get the field key names in a list from the listview
|
||||||
|
List<string> ListViewFieldList = DataList.GetFieldListFromListView(ListViewArray);
|
||||||
List<string> templateFieldList = DataList.GetFieldListFromListView(ListViewArray);
|
|
||||||
|
|
||||||
//BUILD THE QUERY
|
//BUILD THE QUERY
|
||||||
//SELECT FRAGMENT COLUMNS FROM TEMPLATE
|
//SELECT FRAGMENT COLUMNS FROM TEMPLATE
|
||||||
var qSelectColumns = DataListSqlSelectBuilder.Build(DataList.FieldDefinitions, ListViewArray);
|
var qSelectColumns = DataListSqlSelectBuilder.Build(DataList.FieldDefinitions, ListViewFieldList);
|
||||||
|
|
||||||
//FROM CLAUSE
|
//FROM CLAUSE
|
||||||
var qFrom = DataList.SQLFrom;
|
var qFrom = DataList.SQLFrom;
|
||||||
@@ -68,7 +67,7 @@ namespace AyaNova.DataList
|
|||||||
qTotalRecordsQuery = $"SELECT COUNT(*) {qFrom} {qWhere}".Replace(" ", " ");
|
qTotalRecordsQuery = $"SELECT COUNT(*) {qFrom} {qWhere}".Replace(" ", " ");
|
||||||
|
|
||||||
//RETURN OBJECTS
|
//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>>();
|
List<List<AyaFieldData>> rows = new List<List<AyaFieldData>>();
|
||||||
long totalRecordCount = 0;
|
long totalRecordCount = 0;
|
||||||
|
|
||||||
@@ -102,7 +101,7 @@ namespace AyaNova.DataList
|
|||||||
int nCurrentColumnPointer = 1;//start at 1
|
int nCurrentColumnPointer = 1;//start at 1
|
||||||
|
|
||||||
//INSERT REMAINING FIELDS FROM TEMPLATE INTO THE RETURN ROWS LIST
|
//INSERT REMAINING FIELDS FROM TEMPLATE INTO THE RETURN ROWS LIST
|
||||||
foreach (string TemplateField in templateFieldList)
|
foreach (string TemplateField in ListViewFieldList)
|
||||||
{
|
{
|
||||||
//get the AyaObjectFieldDefinition
|
//get the AyaObjectFieldDefinition
|
||||||
AyaDataListFieldDefinition f = DataList.FieldDefinitions.FirstOrDefault(x => x.FieldKey == TemplateField);
|
AyaDataListFieldDefinition f = DataList.FieldDefinitions.FirstOrDefault(x => x.FieldKey == TemplateField);
|
||||||
|
|||||||
@@ -12,24 +12,11 @@ namespace AyaNova.DataList
|
|||||||
internal static class DataListSqlSelectBuilder
|
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
|
//Build the SELECT portion of a list query based on the ListView fields
|
||||||
internal static string Build(List<AyaDataListFieldDefinition> objectFieldsList, JArray listViewArray)
|
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();
|
StringBuilder sb = new StringBuilder();
|
||||||
sb.Append("SELECT ");
|
sb.Append("SELECT ");
|
||||||
|
|
||||||
@@ -50,7 +37,7 @@ namespace AyaNova.DataList
|
|||||||
|
|
||||||
sb.Append(" AS df");
|
sb.Append(" AS df");
|
||||||
|
|
||||||
foreach (string ColumnName in templateFieldList)
|
foreach (string ColumnName in listViewFieldList)
|
||||||
{
|
{
|
||||||
AyaDataListFieldDefinition o = objectFieldsList.FirstOrDefault(x => x.FieldKey == ColumnName);
|
AyaDataListFieldDefinition o = objectFieldsList.FirstOrDefault(x => x.FieldKey == ColumnName);
|
||||||
#if (DEBUG)
|
#if (DEBUG)
|
||||||
|
|||||||
Reference in New Issue
Block a user