Hello Gen Pro fam,
First off, this tools has been the foundation for many of my projects for over in the past year. Excellent work by Frans and the whole LLBL design team.
With that said, I have run into my first issue with the tool. I am using a typedlist to query a random set of data from SQL 2005. Usind the method:
DataAccessAdapter.FetchTypedList(ITypedListLgp2 typedListToFill, IPredicateExpression additionalFilter, int maxNumberOfItemsToReturn, ISortExpression sortClauses, bool allowDuplicates)
The sortClauses contains the NEWID() trick:
IEntityField2 newIDField = EntityFieldFactory.Create(DbEntityFieldIndex.EntityId);
newIDField.Alias = "NEWID()";
newIDField.ExpressionToApply = new Expression();
But issue is when the maxNumberOfItemsToReturn parameter is set to a > 0 value and the allowDuplicates parameter is set to false. The query executes, but the list of results are not limited or distinct. For example:
If I want to retreive only the top 10, distinct rows from a random result list of 200 rows. The returned list will contain all 200 rows. It seems that the method is ignoring the maxNumberOfItemsToReturn and allowDuplicates value when generating the query.
But if you remove the NEWID() from the sortClause, the maxNumberOfItemsToReturn and allowDuplicates value is obeyed and generated in the query.
These results where confirmed using SQL Profiler. Also, if take the query that what generated from LLBL and add the DISTINCT TOP 10 to it and run it in SQL Management Studio, the query runs fine and returns the unique top 10 rows from the query.
Any help/ideas on how to fix this issue would be helpful.
I am using LLBL v 2.5, June 3rd build.
Thanks,