Hi all,
I'm trying to sort a collection as follows (Using the Adapter Method):
Dim _SE As SortExpression = New SortExpression
_SE.Add(New SortClause(CategoryFields.CategoryName, SortOperator.Ascending)) <-- Error Here.
But I'm getting the following error:
System.InvalidCastException was unhandled
Message="Unable to cast object of type 'SD.LLBLGen.Pro.ORMSupportClasses.EntityField2' to type 'SD.LLBLGen.Pro.ORMSupportClasses.IEntityField'."
Source="CBO.BusinessLayer"
StackTrace:
at CBO.BusinessLayer.Categories.GetCategories(String Type) in D:\Personal Programming Projects\DateOMatic\CBO.BusinessLayer\Categories.vb:line 11
at CBO.TestUtility.Main.DataBindCategories() in D:\Personal Programming Projects\DateOMatic\CBO.TestUtility\Main.vb:line 33
at CBO.TestUtility.Main.Main_Load(Object sender, EventArgs e) in D:\Personal Programming Projects\DateOMatic\CBO.TestUtility\Main.vb:line 28
at System.EventHandler.Invoke(Object sender, EventArgs e)
at System.Windows.Forms.Form.OnLoad(EventArgs e)
at System.Windows.Forms.Form.OnCreateControl()
at System.Windows.Forms.Control.CreateControl(Boolean fIgnoreVisible)
at System.Windows.Forms.Control.CreateControl()
at System.Windows.Forms.Control.WmShowWindow(Message& m)
at System.Windows.Forms.Control.WndProc(Message& m)
at System.Windows.Forms.ScrollableControl.WndProc(Message& m)
at System.Windows.Forms.ContainerControl.WndProc(Message& m)
at System.Windows.Forms.Form.WmShowWindow(Message& m)
at System.Windows.Forms.Form.WndProc(Message& m)
at System.Windows.Forms.Control.ControlNativeWindow.OnMessage(Message& m)
at System.Windows.Forms.Control.ControlNativeWindow.WndProc(Message& m)
at System.Windows.Forms.NativeWindow.DebuggableCallback(IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam)
at System.Windows.Forms.SafeNativeMethods.ShowWindow(HandleRef hWnd, Int32 nCmdShow)
at System.Windows.Forms.Control.SetVisibleCore(Boolean value)
at System.Windows.Forms.Form.SetVisibleCore(Boolean value)
at System.Windows.Forms.Control.set_Visible(Boolean value)
at System.Windows.Forms.Application.ThreadContext.RunMessageLoopInner(Int32 reason, ApplicationContext context)
at System.Windows.Forms.Application.ThreadContext.RunMessageLoop(Int32 reason, ApplicationContext context)
at System.Windows.Forms.Application.Run(ApplicationContext context)
at Microsoft.VisualBasic.ApplicationServices.WindowsFormsApplicationBase.OnRun()
at Microsoft.VisualBasic.ApplicationServices.WindowsFormsApplicationBase.DoApplicationModel()
at Microsoft.VisualBasic.ApplicationServices.WindowsFormsApplicationBase.Run(String[] commandLine)
at CBO.TestUtility.My.MyApplication.Main(String[] Args) in 17d14f5c-a337-4978-8281-53493378c1071.vb:line 81
at System.AppDomain.nExecuteAssembly(Assembly assembly, String[] args)
at System.AppDomain.ExecuteAssembly(String assemblyFile, Evidence assemblySecurity, String[] args)
at Microsoft.VisualStudio.HostingProcess.HostProc.RunUsersAssembly()
at System.Threading.ThreadHelper.ThreadStart_Context(Object state)
at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state)
at System.Threading.ThreadHelper.ThreadStart()
I just noticed in the manual that to sort with an adapter you have to use:
Dim _SE As SortExpression = New SortExpression
_SE.Add(New SortClause(CategoryFields.CategoryName, Nothing, SortOperator.Ascending))
I've noticed this in several places in LLBLGen that it would take a parameter even though it is not of the same type ... Is this because I don't have Option Strict turned on in VB.NET? Is there a way to make LLBLGen generated code more strict in terms of which parameters it'll accept so I don't get weird errors like the above?