In Csla 1.5 I had a BusinessBase class and a BusinessCollectionBase class. This allowed me to declare a variable like so:
public IList<BusinessCollectionBase> DetailTables;
I have tried everything I can think of to declare a similar variable in 2.0. I was only able to do this:
public IList<IEditableCollection> DetailTables;
But then this code breaks:
foreach (BusinessBase obj in DetailTables[ii])
It tells me "foreach statement cannot operate on variables of type 'Csla.Core.IEditableCollection' because 'Csla.Core.IEditableCollection' does not contain a public definition for 'GetEnumerator'"
Basically, I need to be able to do two things in 2.0 that I can't figure out yet:
a.) declare a variable whose type is a list of BusinessListBase objects
b.) enumerate through that list and call methods from BusinessBase on each object in each list
Is this even possible with the new generic<t,c> structure? It seems very limiting in this regard...
TIA,
Mike Rodriguez
You will need to translate the following VB suggestions into C#.
Csla.BusinessListBase is a MustInherit class, from which you can derive a collection class like:
Public Class AddressCollection
Inherits Csla.BusinessListBase(Of AddressCollection, Address)
End Class
For this to work, you will also need
Public Class Address
Inherits Csla.BusinessBase(Of Address)
End Class
You can now do
Dim Coll as AddressCollection = AddressCollection.GetAddressCollection(.....)
For each obj as Address in Coll
obj.city = "Chicago"
End For
I hope this helps.
Jav
Hi Jav,
That works fine if you know the type. My collection is generic (not literally) and the type won’t be known until runtime. It was easy to make a generic list of the type BusinessListBase before, then at runtime fill it with different classes. You can’t do that now in 2.0 because you need specific type info.
Thanks,
Mike
Copyright (c) Marimer LLC