I am creating a new entity and in one of the collections of the entity, I'm adding a few items by default. however, when i try to use the added items I get a out of sync exception. What's the best way to add default items to an new entity's collection? It's an Oracle db. Here is the code:
TestPlanEntity toReturn = new TestPlanEntity();
DataAccessAdapter adapter = new DataAccessAdapter();
adapter.FetchEntity(toReturn);
//set defaults
toReturn.LegalEquipmentType = "Information Technology Equipment";
toReturn.ReceivedDate = DateTime.Today;
// add a test for each test_type
TestPlanTestRequestEntity test;
TestTypeListTypedView tests = ListManager.GetTestTypes();
for (int i = 0; i < tests.Rows.Count; i++)
{
test =(TestPlanTestRequestEntity) toReturn.TestPlanTestRequests.AddNew();
test.TestFlag = "T";
test.TestTypeId = Convert.ToInt64(tests.Rows[i][0]);
TestTypeEntity tt= new TestTypeEntity(test.TestTypeId);
adapter.FetchEntity(tt);
test.TestType = tt;
}
Notes:
test.TestType is a foreign table which contains the description for TestTypeId. When I retrieve an existing object, it's easy because I can use the PrefetchPath to get all the related values.
ListManager.GetTestTypes() returns a value/description pair of rows from the db.
The exception will be thrown when, for example, I use this line of code:
int id = testPlan.ProductTypeId; // testPlan is the same object as toReturn
Thanks.