New Posts New Posts RSS Feed: Changetracking  ComplexProperty
  FAQ FAQ  Forum Search   Calendar   Register Register  Login Login

Changetracking ComplexProperty

 Post Reply Post Reply
Author
JJANSSEN View Drop Down
Newbie
Newbie


Joined: 25-Aug-2011
Posts: 10
Post Options Post Options   Quote JJANSSEN Quote  Post ReplyReply Direct Link To This Post Topic: Changetracking ComplexProperty
    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


Edited by JJANSSEN - 13-May-2013 at 6:26am
Back to Top
sbelini View Drop Down
IdeaBlade
IdeaBlade
Avatar

Joined: 13-Aug-2010
Location: Oakland
Posts: 786
Post Options Post Options   Quote sbelini Quote  Post ReplyReply Direct Link To This Post Posted: 13-May-2013 at 11:56am
Hi JJanssen,

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

Regards.
Back to Top
sbelini View Drop Down
IdeaBlade
IdeaBlade
Avatar

Joined: 13-Aug-2010
Location: Oakland
Posts: 786
Post Options Post Options   Quote sbelini Quote  Post ReplyReply Direct Link To This Post 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.
Back to Top
JJANSSEN View Drop Down
Newbie
Newbie


Joined: 25-Aug-2011
Posts: 10
Post Options Post Options   Quote JJANSSEN Quote  Post ReplyReply Direct Link To This Post 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


Edited by JJANSSEN - 30-Jul-2013 at 6:38am
Back to Top
sbelini View Drop Down
IdeaBlade
IdeaBlade
Avatar

Joined: 13-Aug-2010
Location: Oakland
Posts: 786
Post Options Post Options   Quote sbelini Quote  Post ReplyReply Direct Link To This Post Posted: 01-Aug-2013 at 5:21pm
Hi JJanssen,

We are working on a fix for this bug.

Back to Top
 Post Reply Post Reply

Forum Jump Forum Permissions View Drop Down