self-tracking-entities


Enable ChangeTracking In Child Objects Using STE


I'm using STE and I want to enable change tracking for an object and its children. What I currently have to do now is something like this.
int id = 1;
using(CustomerEntities context = new CustomerEntities())
{
CustomerSection custSection = context.CustomerSections.Include("CustomerSections.Customers").SingleOrDefault(p => p.ID == id);
custSection.StartTracking();
foreach(Customer cust in custSection.Customers)
{
cust.StartTracking();
{
return custSection;
}
What I am looking for is a way to automatically enable change tracking for the child objects too, without having to loop through each one and explicitly tell it to start tracking changes.
Thanks in advance for any insight.
Most probably you are using Self Tracking entities in combination with WCF. Then it's not needed to enable the changetracking manually. this is already done for you. The T4 template that generates the STE's includes a method decorated with the [OnDeserialized] attribute which starts the tracking once entities are deserialized (which occurs normally after reaching the client and converted back into runtime class instances fromout the xml that WCF generated for the transport. See the exact code example:
[OnDeserialized]
public void OnDeserializedMethod(StreamingContext context)
{
IsDeserializing = false;
ChangeTracker.ChangeTrackingEnabled = true;
}
Search your entities or the T4 template and you will find this soon.

Related Links

Enable ChangeTracking In Child Objects Using STE

Categories

HOME
opengl
svn
lambda
verification
freeradius
ontouchlistener
openxml
seedstack
twitter-fabric
portable-class-library
tcp
openflow
ag-grid
distributed-computing
texas-instruments
rpmbuild
amazon-mws
social-tables
gitkraken
data-type-conversion
weex
device
animated-gif
vuforia
webviewclient
tsung
sparkle
dotcms
windowsiot
polyml
des
subclassing
landscape
assertions
ms-dos
secure-coding
type-inference
flume-twitter
.net-micro-framework
webalizer
sonatype
gtk#
htmlspecialchars
dex
google-shopping-api
nitrousio
bigdecimal
bilinear-interpolation
clp
svnserve
qpixmap
noclassdeffounderror
apple-configurator
jeditable
preferenceactivity
android-expansion-files
wif4.5
wikimedia-commons
ui4j
deeplink
arbre
ora-04091
asp.net-web-api-helppages
bjam
knife
roxygen2
bootstrap-wysiwyg
mutators
debug-symbols
sql-processor
n-tier-architecture
flurry-analytics
nidaqmx
osascript
nosql-aggregation
django-settings
colon
coalesce
disjoint-union
sunstudio
web-frameworks
reentrancy
jquery-cycle
gitx
workflow-manager-1.x
opends
django-apps
delphi-prism
groovy-console
representation
firefly-mv
cewolf

Resources

Encrypt Message