no setter on EntityCollection

Posts   
 
    
neilx
User
Posts: 267
Joined: 02-Nov-2007
# Posted on: 24-Mar-2010 23:59:21   

It would be good if I could create test data by filling related collections using a setter. Unfortunately setters don't exist for related entity collections in the Adapter template, although they do exists for related entities . Here is some code I would like to use:


var testData = new IislogRegulationEntity
                               {
                                   LogID = 1,
                                   RegID = 1,
                                   RegulationBase = new RegulationBaseEntity
                                     {
                                                RegID = 1,
                                                ReferenceDate = DateTime.Now,
                                                RegulationReference = "reference 1",
                                                Archived = false,
                                                RegulationCountryRegion = new EntityCollection<RegulationCountryRegionEntity>(new List<RegulationCountryRegionEntity>()) // this line fails as there is no setter for RegulationCountryRegion 
                                     }
                               }
                       };

Would it be worth my while changing the Adapter template to add setters to related collections? (I have no idea how to do this, but if it is feasible then I will give it a try)

Walaa avatar
Walaa
Support Team
Posts: 14994
Joined: 21-Aug-2005
# Posted on: 25-Mar-2010 10:28:30   

Yes this feasible. Just take care of the following:

The collections contained in entity X know they're in entity X due to the collection.SetContainingEntityInfo(containingEntity, propertyName) call, so reverse relationships can be maintained automatically. You have to make sure that's done as well in your modification.

neilx
User
Posts: 267
Joined: 02-Nov-2007
# Posted on: 25-Mar-2010 11:45:20   

Thanks very much. I'll give it a try.