This is a migrated thread and some comments may be shown as answers.

Context Change Tracking

2 Answers 54 Views
Development (API, general questions)
This is a migrated thread and some comments may be shown as answers.
This question is locked. New answers and comments are not allowed.
Paresh
Top achievements
Rank 1
Paresh asked on 15 Sep 2014, 10:48 PM
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 Answers, 1 is accepted

Sort by
0
Paresh
Top achievements
Rank 1
answered on 16 Sep 2014, 11:41 PM
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
0
Kaloyan Nikolov
Telerik team
answered on 18 Sep 2014, 04:51 PM
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.
 
Tags
Development (API, general questions)
Asked by
Paresh
Top achievements
Rank 1
Answers by
Paresh
Top achievements
Rank 1
Kaloyan Nikolov
Telerik team
Share this question
or