Create WPF Browser From SubSonic 2.2 Collection

If I have a DAL generated by SubSonic 2.2, how do I convert the collections it creates to WPF ObservableCollections in the code (pref.VB.NET) that WPF will use?

+1


a source to share


2 answers


Sorry! VB:



[Test]
public void Exec_Testing()
{
    ProductCollection products =
        DB.Select().From("Products")
            .Where("categoryID").IsEqualTo(5)
            .And("productid").IsGreaterThan(50)
            .ExecuteAsCollection<ProductCollection>();

    Assert.IsTrue(products.Count == 77);

    ObservableCollection<Product> obsProducts = new ObservableCollection<Product>(products);
}

      

0


a source


You will have to manually add this to your DAL classes, but it is not too difficult. At the top of each data access layer class, add "Implements INotifyPropertyChanged" and then in each property add the code to "set" as shown below.



Private _Book As String
Public Property Book() As String
    Get
        Return _Book
    End Get
    Set(ByVal value As String)
        If Not _Book = value Then
            _Book = value
            ' Raise the property changed event.
            RaiseEvent PropertyChanged(Me, New PropertyChangedEventArgs("Book"))
        End If
    End Set
End Property 

Public Event PropertyChanged(ByVal sender As Object, ByVal e As System.ComponentModel.PropertyChangedEventArgs) Implements System.ComponentModel.INotifyPropertyChanged.PropertyChanged

      

0


a source







All Articles