Hi,
I have some code that returns a lot of rows. To optimize performance and because I only need about 100 rows I have set maxNumberOfItemsToReturn to 100.
Using profiler I can see that this isn't reflected in the query.
Is it possible to get this to work?
Version: LLBLgen Pro 1.2005.1 May 2th
Selfserving
Using MS SQL server 2005
int siteGuid = 10382;
int languageGuid = 1;
string search = "%guld%";
int maxResults = 100;
CommerceItemCollection itemCollection = new CommerceItemCollection();
IPredicateExpression filter = new PredicateExpression();
filter.Add(CommerceItemFields.SiteGuid == siteGuid);
filter.Add(CommerceItemTextFields.LanguageGuid == languageGuid);
filter.Add(CommerceItemTextFields.Name % search);
SortExpression sortExpression = new SortExpression();
sortExpression.Add(CommerceItemTextFields.Name | SortOperator.Ascending);
IRelationCollection relations = new RelationCollection();
relations.Add(CommerceItemEntity.Relations.CommerceItemTextEntityUsingItemGuid);
itemCollection.GetMulti(filter, maxResults, sortExpression,relations);
Generated query
exec sp_executesql N'SELECT [masterpiece].[dbo].[TBLcommerce_item].[Guid], [masterpiece].[dbo].[TBLcommerce_item].[SiteGuid], [masterpiece].[dbo].[TBLcommerce_item].[DateCreated], [masterpiece].[dbo].[TBLcommerce_item].[ItemNo], FROM ( [masterpiece].[dbo].[TBLcommerce_item] INNER JOIN [masterpiece].[dbo].[TBLcommerce_itemText] ON [masterpiece].[dbo].[TBLcommerce_item].[Guid]=[masterpiece].[dbo].[TBLcommerce_itemText].[ItemGuid]) WHERE ( ( [masterpiece].[dbo].[TBLcommerce_item].[SiteGuid] = @SiteGuid1 AND [masterpiece].[dbo].[TBLcommerce_itemText].[LanguageGuid] = @LanguageGuid2 AND [masterpiece].[dbo].[TBLcommerce_itemText].[Name] LIKE @Name3)) ORDER BY [masterpiece].[dbo].[TBLcommerce_itemText].[Name] ASC',N'@SiteGuid1 int,@LanguageGuid2 int,@Name3 nvarchar(6)',@SiteGuid1=10382,@LanguageGuid2=1,@Name3=N'%guld%'
By removing my SortExpression a "TOP" will be reflected in the query, but that's not an option.
The code above have also been tested in LLBLgen 2.5 Final (December 5th, 2007) with same result.
Regards,
Jacob Andersen