I have a method Which takes a list of objects.
Before persisting the object I have to remove some of them on some given condition
for eg(not the ideal!):
A Company can have an Id and a list of Branches and a IsDeleted flag.
A Branch can have an Id and a list of Managers and a IsDeleted flag
A Manager can have an Id and a IsDeleted flag
Company –>Branches–>Managers
Whats the easy or the best way of filtering to ommit the combination of Id = 0 and IsDeleted = True so I can iterate that and do specifics — see the function below
- Thats if the company is marked as
Id = 0 and IsDeletedthen I want to ommit that altogether - But If Only Branch Is marked as
Id=0 and Isdeletedthen the Company Should be there without a Branch - If Only the Manager is matrked as
Id=0 and Isdeletedthen the Company and Branch should be there
Private Function(comp as List(Of Company)) as Boolean
'filter comp here and pass it to for loop??
Dim filteredList as ...
For each c as Company in filteredList
'do company specifis here
For each b as Branch in c.Branches
'do branch specific here
For Each m as Manager in b.Managers
'do manager specific here
Next
Next
Save(c) ' saves child objects as well
Next
End Function
Would this solve your problem?