Tricky list problem

Tricky list problem

Old forum URL: forums.lhotka.net/forums/t/808.aspx


Bonio posted on Thursday, August 03, 2006

I have an EO named 'Customer' that keeps a collection of 'CustomerContact' objects in a Editable Child List named 'CustomerContactList', e.g.:

Customer

      - CustomerContactList

            - CustomerContact

In CustomerContact there is a boolean property 'DefaultBilling' that must only be true for one item in the collection at one time. I have tried putting a loop in the 'set' property to check all items in the parenet list and set as necessary, but without success.

Any ideas how this can be done? In a nutshell, when the DefaultBilling property of a CustomerContact is set to true, I need to loop through the parent list to make sure no other CustomerContacts have this property set to true.

Help gratefully appreciated,

 

Bonio

Bonio replied on Thursday, August 03, 2006

I think I have found the answer to my own problem. I have done the following:

set

{

CanWriteProperty("DefaultShipping", true);

if (!_defaultShipping.Equals(value))

{

CustomerContactList _list = Parent as CustomerContactList;

foreach(CustomerContact cont in _list)

{

if(cont!=this)

{

cont._defaultShipping = false;

cont.MarkDirty();

}

}

_defaultShipping = value;

PropertyHasChanged("DefaultShipping");

}

}

Copyright (c) Marimer LLC