Click here to Skip to main content
15,885,032 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
Hello there guys

I'm using entity framework 5,

is it possible, or is there a way of only detect changes in a single instance of an object rather than the all object context?

what i want to do is like:

Person person = new Person();

person. // make some changes here

person.DetectChanges();

rather than:

Person person = new Person();

person. // make some changes here

allObjectContext.DetectChanges();



I'm i making sense?

Plz let me know!

Thanks!
Posted

The first question is Why?? Since you're making a new Person object, nearly everything will be a change. The only things that won't will be the default values for your object property types, like 0 for an int.
 
Share this answer
 
Hello there and thanks for the reply.

What i want to do is when i set a property on an instance, if I use "DetectChanges()" it automatically populates the navigational property and vice-versa.

What is happening is that the detect changes detect that to ALL the objects loaded in the object context, and, in my case, the database is remote, so it takes a while.

Lets say, it take like 2-3 seconds detecting the changes of 3000 records.

I want to do that (load navigational properties) in a single record to improve time.

Thanks!
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
Top Experts
Last 24hrsThis month


CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900