gladly.
The main object i am dealing with is an EvidenceEntity. It contains a Collection of EvidenceQuestionGroupAssignments. This collection of entities relates my Evidence to a set of QuestionGroups.
What i have is a usercontrol which is basically managing a grid of these EvidenceQuestionGroupAssignments. It can create new assignments and edit existing ones (including creating QuestionGroups etc.)
This user control in additon to persisting it's colection of entities, also persists the EvidenceEntity in order to have it ot create new EvidenceQuestionGroupAssignments. These are created basically like this:
Dim eqga As New EvidenceQuestionGroupAssignmentEntity
With eqga
.Evidence = evidence ' the persisted evidence
.QuestionGroup = group
End With
I have begun by retrieving the collection EvidenceQuestionGroupAssignments from the original Evidence, like so:
Public Sub SetFromExistingEvidence(ByVal evidence As EvidenceEntity)
Me.Reset()
Me.SelectedQuestionGroupAssignments.AddRange(evidence.EvidenceQuestionGroupAssignment)
' sort the collection
Me.SelectedQuestionGroupAssignments.Sort(EvidenceQuestionGroupAssignmentFields.SortOrder.FieldIndex, ComponentModel.ListSortDirection.Ascending)
Me.BindSelectedQuestionGroups() ' bind the usercontrol
Me.PersistSelectedQuestionGroupAssignments() ' persists the collection
End Sub
The collection that im interested in here is being "double persisted" -- once as the collection SelectedQuestionGroupAssignments persisted in my usercontrol (session or viewstate or whatever), and a second time as the collection belonging to the Evidence (myEvidence.EvidenceQuestionGroupAssignments) which has also been persisted to session.
So i would like to persist the Evidence (myEvidence) so ican use it to create assignements, but not persist myEvidence.EvidenceQuestionGroupAssignments.
Bear in mind that in some contexts we are talking about evidence that comes from DB storage (i.e. has a PK) but in other contexts it may not yet be in teh DB (has yet to be saved) so just can't retrieve it every time.