We have used the datasource(LLBLGenProDataSource2) whose LivePersistence is false.
And it have been assigned to a datagrid.
We are using the PerformSelect for the Datasource(coding)
Protected Sub dsIssue_PerformSelect(ByVal sender As Object, ByVal e As SD.LLBLGen.Pro.ORMSupportClasses.PerformSelectEventArgs2)
.....
Dim newExpression As New SortExpression
newExpression.Add(New SortClause(New EntityProperty("IssueType"), Nothing, SortOperator.Ascending))
adapter.FetchEntityCollection(ecIssue, filter, Nothing, newExpression)
.....
End Sub
Here it produces the error
Unable to cast object of type 'SD.LLBLGen.Pro.ORMSupportClasses.EntityProperty' to type 'SD.LLBLGen.Pro.ORMSupportClasses.IEntityField2'.
Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.
Exception Details: System.InvalidCastException: Unable to cast object of type 'SD.LLBLGen.Pro.ORMSupportClasses.EntityProperty' to type 'SD.LLBLGen.Pro.ORMSupportClasses.IEntityField2'.
We cant directly use
newExpression.Add(IssueFields.IssueType, Nothing, SortOperator.Ascending))
instead of
newExpression.Add(New SortClause(New EntityProperty("IssueType"), Nothing, SortOperator.Ascending))
because the field to be sorted would be found at run time only.So we will be passing the fieldheader as string.
How to solve this casting problem?