Beispiel #1
0
        public static void ConstructDataSourceObjectFromPostRequest(JSONDataSource jsonDS, ref SqlBuilderColumnSelection requestedCols, ref SqlBuilderColumnSelection workingSelCols,
                                                                    ref SqlBuilderColumnSelection distinctSelCols, ref OrderBy orderBy, ref KeylessVirtualTable table)
        {
            DataSource ds = new DataSource();

            ds.Initialize(jsonDS.Name, DatabaseObjects.GetTableObject(jsonDS.Table), jsonDS.PageSize, jsonDS.PageIndex, jsonDS.GenerateTotal);

            if ((jsonDS.JSelectItems != null))
            {
                foreach (JDataSourceSelectItem jsonSItem in jsonDS.JSelectItems)
                {
                    ds.AddSelectItem(ConstructSelectItemFromPostRequest(jsonSItem));
                }
            }

            requestedCols   = new SqlBuilderColumnSelection(jsonDS.ExpandForeignKeyColumns, jsonDS.IsDistinct);
            workingSelCols  = new SqlBuilderColumnSelection(jsonDS.ExpandForeignKeyColumns, jsonDS.IsDistinct);
            distinctSelCols = new SqlBuilderColumnSelection(jsonDS.ExpandForeignKeyColumns, jsonDS.IsDistinct);

            List <BaseColumn> columnsList = null;

            if (jsonDS.isTotalRecordArray)
            {
                columnsList = ds.CreateColumnSelectionsForTotal(ref requestedCols, ref workingSelCols, ref distinctSelCols);
            }
            else
            {
                columnsList = ds.CreateColumnSelections(ref requestedCols, ref workingSelCols, ref distinctSelCols);
            }
            table = ds.CreateVirtualTable(columnsList.ToArray());

            if ((jsonDS.JOrderByList != null))
            {
                foreach (JOrderBy jsonOrderBy in jsonDS.JOrderByList)
                {
                    ds.AddAggregateOrderBy(jsonOrderBy.ColumnName, OrderByItem.ToOrderDir(jsonOrderBy.OrderDirection));
                }
            }
            ds.UpdateOrderBy(columnsList);
            orderBy = ds.OrderBy;
        }