I am using LLBLGen 2.6, adapter, Winforms application, with a MySql database.
I am showing a dialog to allow users to add Items to a related collection of an object. The items can only be chosen from a list of available items. The main item loaded with the form is a Route (train route). There are two listboxes, showing stations already assigned to the route, and stations available to assign.
I want the users to be able to select from the list of available stations and press an 'Add' button (to add stations to the route), or press a 'Remove' button to do the reverse.
The database structure contains a Routes table, a RouteStations table (with FK_Route, FK_Station and StationOrder), and a Stations table.
I can initially get the list of Stations for the Route by accessing Route.StationCollectionViaRouteStations - and then set that as the DataSource of the listbox.
I'm assuming there's an easy way of applying a filter to the DefaultView of the complete list of Available stations (for the other listbox) using Route.StationCollectionViaRoute? That's my first question - how to apply that filter in memory, and to reapply it every time the items in the other listbox change.
Given that the Order of the stations on a Route is determined by the linking table ('RouteStations.StationOrder'), how would I maintain an ordered list of station objects? I'm thinking the best way would be to create a dummy custom order field for the Station Entity, just to use during this operation. So my second question is, how could I add a custom field and then use it in a 'new SortExpression' statement on the View?