LLBLGenPro version: 2.6 Final (October 9, 2009)
File Version on SupportClasses DLL: 2.6.09.0903
Using Self Servicing with .NET 3.5 and SqlServer 2005
Code in question:
// construct custom sort expresssion
// (sorts by bytes 10 and 11 of LabelDescription field)
object[] substringParameters = { SettingsFields.LabelDescription, 10, 2 };
DbFunctionCall substringCall = new DbFunctionCall("SUBSTRING", substringParameters);
EntityField sortField = new EntityField("ServiceSortOrder", substringCall);
SortClause serviceSortOrderClause = new SortClause(sortField, null, SortOperator.Ascending);
serviceSortOrderClause.EmitAliasForExpressionAggregateField = false;
SortExpression sorter = new SortExpression(serviceSortOrderClause);
// resort and project collection
SettingsCollection inSvcSettings = (SettingsCollection)InSvcSettingsDataSource.EntityCollection;
[colorvalue="FF0000"][b]// exception occurs on the next statement[/b][/color]
EntityView<SettingsEntity> inSvcSettingsView =
new EntityView<SettingsEntity>(inSvcSettings, sorter);
List<IEntityPropertyProjector> propertyProjectors =
EntityFields.ConvertToProjectors(inSvcSettings.EntityFactoryToUse.CreateFields());
SettingsCollection inSvcSortedSettings = new SettingsCollection();
inSvcSettingsView.CreateProjection(propertyProjectors, inSvcSortedSettings);
Exception text:
The expression object set for entity field 'ServiceSortOrder' isn't implementing IExpressionInterpret
Stack Trace:
at SD.LLBLGen.Pro.ORMSupportClasses.EntityFieldCore.SD.LLBLGen.Pro.ORMSupportClasses.IEntityFieldCoreInterpret.GetValue(IEntityCore entity)
at SD.LLBLGen.Pro.ORMSupportClasses.EntityViewBase`1.SortIndices(List`1 listToSort, ISortExpression sorter, Int32 indexInSortExpression)
at SD.LLBLGen.Pro.ORMSupportClasses.EntityViewBase`1.SetSorter(ISortExpression sorter)
at SD.LLBLGen.Pro.ORMSupportClasses.EntityViewBase`1.InitClassCore(CollectionCore`1 relatedCollection, IPredicate filterToApply, ISortExpression sorterToApply, PostCollectionChangeAction dataChangeAction)
at SD.LLBLGen.Pro.ORMSupportClasses.EntityView`1..ctor(EntityCollectionBase`1 relatedCollection, IPredicate filter, ISortExpression sorter, PostCollectionChangeAction dataChangeAction)
at SD.LLBLGen.Pro.ORMSupportClasses.EntityView`1..ctor(EntityCollectionBase`1 relatedCollection, ISortExpression sorter)
at SbsController.UI.MfcParametersForm.PageSpecificOk() in B:\\jkelly_laptop_SbsController_view\\sdnyct\\sbsController\\src\\ui\\MfcParametersForm.aspx.cs:line 202" string
Is it not possible to use this kind of custom sort with an entity view? Is there an alternate way to sort this collection in memory and project to another collection?