I need to make Root object that this is a collection of other objects. So in the update method would it be ok to create the connection to the database in the overridden method DataPortal_Update() of the Collection object then reuse that connection to work with the objects in the collection like so:
protected
override void DataPortal_Update(){
RaiseListChangedEvents =
false; using (SqlConnection cn = new SqlConnection(Database.CustomerDB)){
foreach (Customer cust in DeletedList)cust .DeleteSelf(cn);
DeletedList.Clear();
foreach (Customer cust in this) if (cust .IsNew)cust .Insert(cn,
this); elsecust .Update(cn,
this);RaiseListChangedEvents =
true;}
}
RangerGuy,
All root objects including editable root list uses DataPortal_Update method so your implementation is correct.
Create connection in this method is also an acceptable method. In fact its a good way to avoid dtc from kicks in sql2k5 when using TtransactionScope.
You don't need to pass your current object (list object) when calling insert or update method though.
Ricky
Copyright (c) Marimer LLC