Print Page | Close Window

Changetracking ComplexProperty

Printed From: IdeaBlade
Category: DevForce
Forum Name: DevForce 2010
Forum Discription: For .NET 4.0
URL: http://www.ideablade.com/forum/forum_posts.asp?TID=4148
Printed Date: 23-May-2024 at 3:21am


Topic: Changetracking ComplexProperty
Posted By: JJANSSEN
Subject: Changetracking ComplexProperty
Date Posted: 13-May-2013 at 4:21am
Working with changetracking and complex property:


            entity.Period = new Period(new DateTime(2000,01,01), new DateTime(2222,01,01));
            entity.EntityAspect.AcceptChanges();
            entity.Period = new Period(new DateTime(9000,01,01), new DateTime(9999,01,01));

            var complexProperty = entity.EntityAspect.EntityMetadata.ComplexTypeProperties.
                                                       First(c => c.PropertyInfo.Name.Equals("Period"));
          
            var currentComplexObj = complexProperty.GetValue(entity, EntityVersion.Current);
            var orginalComplexObj = complexProperty.GetValue(entity, EntityVersion.Original);

The value of the object currentComplexObj is new Period(new DateTime(9000,01,01), new DateTime(9999,01,01)) <- this is right.
The value of the object orginalComplexObj is new Period(new DateTime(9000,01,01), new DateTime(9999,01,01)) <- this is wrong.

What am I doing wrong? Where can i get the old original value from the complex property?
Sincere regards, Johannes



Replies:
Posted By: sbelini
Date Posted: 13-May-2013 at 11:56am
Hi JJanssen,

I was able to reproduce the issue here and will file a bug report.

Regards.


Posted By: sbelini
Date Posted: 13-May-2013 at 12:17pm
Hello again JJanssen,

I wanted to follow up with you and let you know that, in the meantime, there is a workaround.

Instead of using a constructor for your Complex type
entity.Period = new Period(new DateTime(2000,01,01), new DateTime(2222,01,01));

you can assign each complex type property separately
entity.Period.StartDate = new DateTime(2000,01,01);

entity.Period.EndDate = new DateTime(2222,01,01));

and the issue will be gone.


Posted By: JJANSSEN
Date Posted: 30-Jul-2013 at 5:57am
thanks, for the fix in den 6.1.14
 "Fixed a problem with change tracking of Complex Type properties.  [D2443]"

Now we have another problem when importing the entites of a EntityManager into another in an EntityServerSaveInterceptor. When importing entity with ComplexProperties the original value is lost.

entity11.Period = new Period(new DateTime(9000,01,01), new DateTime(9999,01,01));
entity11.EntityAspect.AcceptChanges();
entity11.Period = new Period(new DateTime(9000,01,01), new DateTime(9999,01,01));
entityManager11.AddEntity(entity11);
entityManager22.ImportEntities(entityManager11.
Entities, MergeStrategy.OverwriteChanges);
var entity22 = entityManager22.
Entities.First();

The
changetracking information for entity11 works, but not for the entity22.

Please help us,
Johannes Janssen


Posted By: sbelini
Date Posted: 01-Aug-2013 at 5:21pm
Hi JJanssen,

We are working on a fix for this bug.




Print Page | Close Window