This commit is contained in:
@@ -55,7 +55,7 @@ namespace AyaNova.DataList
|
|||||||
//BUILD THE QUERY
|
//BUILD THE QUERY
|
||||||
|
|
||||||
//SELECT CLAUSE
|
//SELECT CLAUSE
|
||||||
var qSelect = DataListSqlSelectBuilder.Build(DataList.FieldDefinitions, AllUniqueFieldKeysRequiredForQuery);
|
var qSelect = DataListSqlSelectBuilder.BuildForDataTableListResponse(DataList.FieldDefinitions, AllUniqueFieldKeysRequiredForQuery);
|
||||||
|
|
||||||
//FROM CLAUSE
|
//FROM CLAUSE
|
||||||
var qFrom = DataList.SQLFrom;
|
var qFrom = DataList.SQLFrom;
|
||||||
@@ -277,6 +277,10 @@ namespace AyaNova.DataList
|
|||||||
if (DataList is IDataListInternalCriteria)
|
if (DataList is IDataListInternalCriteria)
|
||||||
StaticServerFilterOptions = ((IDataListInternalCriteria)DataList).DataListInternalCriteria(userId, userRoles, dataListSelectionOptions);
|
StaticServerFilterOptions = ((IDataListInternalCriteria)DataList).DataListInternalCriteria(userId, userRoles, dataListSelectionOptions);
|
||||||
|
|
||||||
|
//Add the internal filters into the listoptions existing filters
|
||||||
|
//NOTE: There is currently no overlap between internal filtered columns and filters coming from the client
|
||||||
|
foreach (DataListFilterOption dfo in StaticServerFilterOptions)
|
||||||
|
dataListSelectionOptions.Filter.Add(dfo);
|
||||||
|
|
||||||
// //Hard coded extra criteria from Client end
|
// //Hard coded extra criteria from Client end
|
||||||
// //parse and combine any additional listview hard coded from Client UI
|
// //parse and combine any additional listview hard coded from Client UI
|
||||||
@@ -289,7 +293,7 @@ namespace AyaNova.DataList
|
|||||||
|
|
||||||
//BUILD THE QUERY
|
//BUILD THE QUERY
|
||||||
//SELECT FRAGMENT COLUMNS FROM TEMPLATE
|
//SELECT FRAGMENT COLUMNS FROM TEMPLATE
|
||||||
var SelectBuild = DataListSqlSelectBuilder.BuildForReportIdListOnly(DataList.FieldDefinitions);
|
var qSelect = DataListSqlSelectBuilder.BuildForIdListResponse(DataList.FieldDefinitions, dataListSelectionOptions);
|
||||||
|
|
||||||
//FROM CLAUSE
|
//FROM CLAUSE
|
||||||
var qFrom = DataList.SQLFrom;
|
var qFrom = DataList.SQLFrom;
|
||||||
@@ -306,7 +310,7 @@ namespace AyaNova.DataList
|
|||||||
//PUT IT ALL TOGETHER
|
//PUT IT ALL TOGETHER
|
||||||
string qDataQuery = string.Empty;
|
string qDataQuery = string.Empty;
|
||||||
|
|
||||||
qDataQuery = $"{SelectBuild.Select} {qFrom} {qWhere} {qOrderBy} ".Replace(" ", " ");
|
qDataQuery = $"{qSelect} {qFrom} {qWhere} {qOrderBy} ".Replace(" ", " ");
|
||||||
|
|
||||||
//RETURN OBJECTS
|
//RETURN OBJECTS
|
||||||
var retList = new List<long>();
|
var retList = new List<long>();
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Text;
|
using System.Text;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
|
using AyaNova.Models;
|
||||||
|
|
||||||
namespace AyaNova.DataList
|
namespace AyaNova.DataList
|
||||||
{
|
{
|
||||||
@@ -13,7 +14,7 @@ namespace AyaNova.DataList
|
|||||||
{
|
{
|
||||||
|
|
||||||
//Build the SELECT portion of a list query based on the columns
|
//Build the SELECT portion of a list query based on the columns
|
||||||
internal static SqlSelectBuilderResult Build(List<DataListFieldDefinition> objectFieldsList, List<string> columns)
|
internal static SqlSelectBuilderResult BuildForDataTableListResponse(List<DataListFieldDefinition> objectFieldsList, List<string> columns)
|
||||||
{
|
{
|
||||||
StringBuilder sb = new StringBuilder();
|
StringBuilder sb = new StringBuilder();
|
||||||
sb.Append("SELECT ");
|
sb.Append("SELECT ");
|
||||||
@@ -33,7 +34,7 @@ namespace AyaNova.DataList
|
|||||||
//Developers little helper
|
//Developers little helper
|
||||||
if (o == null)
|
if (o == null)
|
||||||
{
|
{
|
||||||
throw new System.ArgumentNullException($"## DEV ERROR in DataListSqlSelectBuilder.cs:Build() field {ColumnName} specified in columns was NOT found in the data list's ObjectFields list, a defined fieldkey name differs from the columns key name");
|
throw new System.ArgumentNullException($"## DEV ERROR in DataListSqlSelectBuilder.cs:BuildForDataTableListResponse() field {ColumnName} specified in columns was NOT found in the data list's ObjectFields list, a defined fieldkey name differs from the columns key name");
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
if (o != null)
|
if (o != null)
|
||||||
@@ -112,29 +113,67 @@ namespace AyaNova.DataList
|
|||||||
|
|
||||||
|
|
||||||
//Build the SELECT portion of a list query but only to return rowid's
|
//Build the SELECT portion of a list query but only to return rowid's
|
||||||
internal static SqlSelectBuilderResult BuildForReportIdListOnly(List<DataListFieldDefinition> objectFieldsList)
|
|
||||||
|
internal static string BuildForIdListResponse(List<DataListFieldDefinition> fieldDefinitions, DataListSelectionOptions dataListSelectionOptions)
|
||||||
{
|
{
|
||||||
|
//BugBug - is not including internalcriteria OR user filtered columns so they don't filter properly
|
||||||
|
//needs to be there and also return correct 0th column for id filtering or make sure it's always the zeroth I guess
|
||||||
|
|
||||||
StringBuilder sb = new StringBuilder();
|
StringBuilder sb = new StringBuilder();
|
||||||
sb.Append("SELECT ");
|
sb.Append("SELECT ");
|
||||||
//map sql column name to ordinal name
|
//map sql column name to ordinal name
|
||||||
Dictionary<string, int> map = new Dictionary<string, int>();
|
// Dictionary<string, int> map = new Dictionary<string, int>();
|
||||||
|
|
||||||
//find the rowid in the objectfields list and insert it
|
//FIRST: find the rowid in the objectfields list and insert it
|
||||||
var o = objectFieldsList.FirstOrDefault(z => z.IsRowId == true);
|
//this is now the zeroth column
|
||||||
if (o != null)
|
//Note: IsRowId field should *always* exist for any list that is intended to be used in an idlist response
|
||||||
{
|
var o = fieldDefinitions.FirstOrDefault(z => z.IsRowId == true);
|
||||||
var idColumnName = o.SqlIdColumnName;
|
sb.Append(o.SqlIdColumnName);
|
||||||
if (!string.IsNullOrWhiteSpace(idColumnName))
|
// map.Add(o.SqlIdColumnName, 0);
|
||||||
{
|
|
||||||
sb.Append(idColumnName);
|
//Now add any rows found in filter
|
||||||
map.Add(idColumnName, 0);
|
foreach(var filter in dataListSelectionOptions.Filter){
|
||||||
|
//add all columns being filtered but not rowId
|
||||||
|
var fld=fieldDefinitions.FirstOrDefault(z=>z.FieldKey==filter.Column);
|
||||||
|
if(!fld.IsRowId){
|
||||||
|
sb.Append($",{fld.SqlIdColumnName}");
|
||||||
|
//map.Add(fld.SqlIdColumnName);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return new SqlSelectBuilderResult() { map = map, Select = sb.ToString() };
|
|
||||||
|
|
||||||
|
return sb.ToString();
|
||||||
}//eom
|
}//eom
|
||||||
|
|
||||||
|
|
||||||
|
// internal static SqlSelectBuilderResult BuildForReportIdListOnly(List<DataListFieldDefinition> objectFieldsList)
|
||||||
|
// {
|
||||||
|
// //BugBug - is not including internalcriteria columns so they don't filter properly
|
||||||
|
// //needs to be there and also return correct 0th column for id filtering or make sure it's always the zeroth I guess
|
||||||
|
|
||||||
|
// StringBuilder sb = new StringBuilder();
|
||||||
|
// sb.Append("SELECT ");
|
||||||
|
// //map sql column name to ordinal name
|
||||||
|
// Dictionary<string, int> map = new Dictionary<string, int>();
|
||||||
|
|
||||||
|
// //find the rowid in the objectfields list and insert it
|
||||||
|
// var o = objectFieldsList.FirstOrDefault(z => z.IsRowId == true);
|
||||||
|
// if (o != null)
|
||||||
|
// {
|
||||||
|
// var idColumnName = o.SqlIdColumnName;
|
||||||
|
// if (!string.IsNullOrWhiteSpace(idColumnName))
|
||||||
|
// {
|
||||||
|
// sb.Append(idColumnName);
|
||||||
|
// map.Add(idColumnName, 0);
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
|
||||||
|
// return new SqlSelectBuilderResult() { map = map, Select = sb.ToString() };
|
||||||
|
// }//eom
|
||||||
|
|
||||||
|
|
||||||
// //Build the SELECT portion of a list query but only to return rowid's
|
// //Build the SELECT portion of a list query but only to return rowid's
|
||||||
// internal static SqlSelectBuilderResult BuildForReportIdListOnly(List<AyaDataListFieldDefinition> objectFieldsList, List<string> listViewFieldList)
|
// internal static SqlSelectBuilderResult BuildForReportIdListOnly(List<AyaDataListFieldDefinition> objectFieldsList, List<string> listViewFieldList)
|
||||||
// {
|
// {
|
||||||
|
|||||||
Reference in New Issue
Block a user