Context Change Tracking

3 posts, 0 answers
  1. Paresh
    Paresh avatar
    13 posts
    Member since:
    Jul 2014

    Posted 15 Sep 2014 Link to this post

    Hi,

    I have Category and Product two classes in my model. I am using following code to insert products in the system

    Category cat = DBConetxt.Categories.Where(x=>x.id = CategoryId);
    Product xyz = new Product();
    cat.products.add(xyz);

    Before flushing changes into database I am using following code to determine new inserts

    new public void FlushChanges()
    {
    Telerik.OpenAccess.ContextChanges changes = GetChanges();
    foreach (object o in changes.GetInserts<object>())
    {
       eventHandler.OnPreInsert(o);
    }
    foreach (object o in changes.GetUpdates<object>())
    {
       eventHandler.OnPreUpdate(o);
    }
    base.FlushChanges();
    }
            
    I am not getting any onjects from the GetInserts method but flushchanges method is trying to insert new records in database.

    Is there any reason GetInserts method in not returning new records?

    Thanks,
    Paresh
  2. Paresh
    Paresh avatar
    13 posts
    Member since:
    Jul 2014

    Posted 16 Sep 2014 in reply to Paresh Link to this post

    Updates:

    Sorry for confusion but here is the code I am using to insert products into system

    Category cat = DBConetxt.Categories.Where(x=>x.id = CategoryId);
    cat.product = new Product();

    Note there is one to one mapping between product and category it is not a collection.

    Thanks,
    Paresh
  3. DevCraft banner
  4. Kaloyan Nikolov
    Admin
    Kaloyan Nikolov avatar
    118 posts

    Posted 18 Sep 2014 Link to this post

    Hello Paresh,

    Unfortunately I am not able to reproduce the behavior your are describing. I've converted the current thread to private in order to allow you to upload a sample application reproducing the issue in order to help us identifying the problem. 

    For you convenience I am attaching the application I used to test your case. 

    I am looking forward for your additional input. 


    Regards,
    Kaloyan Nikolov
    Telerik
     
    OpenAccess ORM is now Telerik Data Access. For more information on the new names, please, check out the Telerik Product Map.
     
Back to Top