I have nested classes ie
Order
ID, (GUID = 8e6e48f7-9047-4e2a-95e7-ec4318641fbb)
Date
Orders -> List<OrderItem>
OrderItem
ID, (GUID= = 4582234b-d8b5-4665-b00f-e4f09ff3e2c6)
ProductId
Qty
Unit
Price
ID, (GUID= = b0d12322-e92c-42c6-b2b7-520db1d3a818)
ProductId
Qty
Unit
Price
Because I have nesting and I am using GUIDs as IDs for my objects, I am wondering whether there is a generic method to find an object given a GUID. One I have this object I could then remove it from it parent list.
By the way, I do realise that I could used specific lambda expression to get at the specific objects, but this would result in many expressions for many different scenarios, hence many interest in one generic approach.
Thanks,
I would probably create an interface that all of my classes (or base classes) would implement called
IGuidSearchableor something like that. It would need to set two properties, the ID and aChildrencollection ofList<ISearchable>. The implementing classes could either use this or would be responsible for setting this property to be equal to the property they use (likeOrders -> List<OrderItem>in your example).