Thanks Daelmo.
The new approach for the relations is underway, but it might take a while to get that done.
We have a user who wants to use the app and we are looking for an interim solution.
I have never used DynamicList, will take a look at it.
For now I found a work around.
For some reason if the query with columns > 4096 is framed as below it works on SQL Server,
SELECT *
FROM
(
SELECT <LONG LIST OF COLUMNS GREATER THAN 4096>
FROM <WHAT EVER TABLE LIST>
) A
Can you guide me on how to generate the query as above given the final selectList and all other params in CreateSelectDQ?
So far I tried to use a derived table based on the parameters received in the CreateSelectDQ override as given below (ignore the crude form of the code as I quickly wanted to try the idea).
protected override IRetrievalQuery CreateSelectDQ(IEntityFields2 fieldsToFetch, IFieldPersistenceInfo[] persistenceInfoObjects, IPredicateExpression filter, long maxNumberOfItemsToReturn, ISortExpression sortClauses, IRelationCollection relationsToWalk, bool allowDuplicates, IGroupByCollection groupByClause, int pageNumber, int pageSize)
{
var derivedTable = new DerivedTableDefinition(fieldsToFetch, "aa", filter, relationsToWalk, null, groupByClause, 0, allowDuplicates);
for (var i = 0; i < persistenceInfoObjects.Count(); i++)
{
derivedTable.SetFieldPersistenceInfo(persistenceInfoObjects[i], i);
}
var relationCollection = new RelationCollection();
relationCollection.Add(new DynamicRelation(derivedTable));
var resultFields = new ResultsetFields(1);
resultFields.DefineField(new EntityField2("*", derivedTable.Alias, typeof (int)), 0);
var persistenceInfo = new FieldPersistenceInfo("*");
var perInfo = new IFieldPersistenceInfo[1];
perInfo[0] = persistenceInfo;
return base.CreateSelectDQ(resultFields, perInfo, null, maxNumberOfItemsToReturn, sortClauses, relationCollection, allowDuplicates, null, pageNumber, pageSize);
}
So far it looks ok, however am stuck with the issue when sort clauses are specified. Since the the columns are aliased in the subquery, am not sure how to make the order by use the aliased column names instead of the column names used in the sub query.
i.e.
So far I am able to generate something like
SELECT *
FROM (SELECT A.Id AS F1_0, B.Name AS F1_1 FROM A LEFT JOIN B ON A.Id = B.Id)
ORDER BY A.Id, B.Name
as you can see this query would fail.
Any tips on how to make Order By use the final aliases applied to the column.