LLBLGen 3.1 Final - SQL Server 2008 - Using Visual Studio 2010 - VB.NET - WPF
There may be a simple solution for this, but I have not been able to find it yet. Basically,
I am trying to combine entities that may not have specific DB relations and bind them to a WPF multi-select combobox. I would always be using two tables for each scenario and am looking to make this as generic as possible. I would have a Lookup table and and operational table. Due to NDA I cannot post actual object names, but it should be simple enough to describe.
The following SQL statement would accomplish the result I am looking to get:
SELECT t1.IDField AS Id, t1.NameField AS Name, t2.SomeBoolean AS IsChecked
FROM LookupTable AS t1
LEFT OUTER JOIN OperationalTable AS t2 ON t1.IDField = t2.IDField
The sample WPF control in my XAML:
<ComboBox Name="cmbMulti" IsEditable="True" SelectedItem="" IsReadOnly="True" ItemsSource="{Binding MyList}" SelectedValuePath="Id">
<ComboBox.ItemTemplate>
<HierarchicalDataTemplate>
<CheckBox Content="{Binding Name, NotifyOnSourceUpdated=True}" IsChecked="{Binding IsChecked}" Click="CheckBox_Checked" />
</HierarchicalDataTemplate>
</ComboBox.ItemTemplate>
</ComboBox>
Based on the tables below I would expect my multi-select combobox to initialze showing all four items in the lookup tables as the ItemsSource, and would have the two items in the operational table checked via the IsChecked binding.
LookupTable OperationalTable
ID Name ID Name
10 Test1 10 Test1
20 Test2 30 Test3
30 Test3
40 Test4
Out of the box I couldn't find a way to make this happen so I created a class called
"MultiList", which looks as follows:
Public Class MultiList
Implements INotifyPropertyChanged
PropertyStuffHere
Public Sub New(ByVal intId As Integer, ByVal strName As String, ByVal blnIsChecked As Boolean)
Id = intId
Name = strName
IsChecked = blnIsChecked
End Sub
Public Event PropertyChanged(ByVal sender As Object, ByVal e As System.ComponentModel.PropertyChangedEventArgs) Implements System.ComponentModel.INotifyPropertyChanged.PropertyChanged
End Class
End Class
In my main class I have a Public Property called "MyList" implemented as follows:
Public _myList As New List(Of MultiList()
Public Property PriorAidL As List(Of MultiList)
Get
_myList.Add(New MultiList(10, "Test1", True))
_myList.Add(New MultiList(20, "Test2", False))
_myList.Add(New MultiList(30, "Test3", True))
_myList.Add(New MultiList(40, "Test4", False))
Return _myList
End Get
Set(ByVal value As List(Of MultiList))
_myList = value
End Set
End Property
The additions to the list are hardcoded for now as a Proof Of Concept, but doing this work when these objects could come from different Lookup and Operationals tables seems unnecessary. Also, if I checked or unchecked an item from the multi-select control I would expect the EntityCollection to be updated so SaveMulti() could be called against the OperationalTable when changes need to be saved.
My issue is this custom class my not even be necessary at all if LLBLGen has something to offer that allows me to bind this solution and properly JOIN, Save Entities in a more manageable format.
Any assistance would be appreciated greatly.