getting out of sync exception

Posts   
 
    
zmian
User
Posts: 14
Joined: 19-Oct-2005
# Posted on: 19-Oct-2005 05:41:51   

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.

Walaa avatar
Walaa
Support Team
Posts: 14995
Joined: 21-Aug-2005
# Posted on: 19-Oct-2005 15:51:06   

Please refer to the following thread:

http://www.llblgen.com/tinyforum/Messages.aspx?ThreadID=3210

Good Luck

zmian
User
Posts: 14
Joined: 19-Oct-2005
# Posted on: 19-Oct-2005 16:31:59   

Thanks for the reply.