c# - Problems with Dev Force Navigation Properties after multiple cache restores / imports -
c# - Problems with Dev Force Navigation Properties after multiple cache restores / imports -
we've run odd problem in our app navigation property on our entity ends getting 'confused' in doesn't think there entity on other end, when in fact there is. navigation property one-to-one navigation , know we've had other problems one-to-one properties in past maybe we've nail odd border case bug?
in trying reproduce problem in simplest possible way, i've found can reproduce doing entitymanager.cachestatemanager.restorecachestate(somecachestate) twice in row. doing twice causes problem doing 1 time doesn't. in our app, restoring cache state , seems related problem. don't think restoring twice maybe are? either way, seems should fine this?
also, in our real app, can reproduce problem doing importentities on list of 2 entities (the 2 entities participating in one-to-one relationship) twice . in case, don't have odd thing of restoring same cache state twice reproduce problem - import twice. unfortunately, haven't been able reproduce double-import in clean solution.
here sample code demonstrates expected behavior , shows actual behavior:
private static void testmultipleimports() { //any database one-to-one should work. i'm using adventure works here i've modified // have one-to-one relationship. each contact there 0 or 1 contact details // (they both have contactid primary key) var mainem = new adventureworksentities(); //add contact , contact detail same sid var contact = new contact {contactid = 1}; var detail = new contactdetail {contactid = 1}; mainem.attachentity(contact); mainem.attachentity(detail); //devforce correctly matched entities navigating contact detail or // detail contact works expected assert.aresame(detail, contact.contactdetail); assert.aresame(contact, detail.contact); //in entity manager, add together same contact , details var altem = new adventureworksentities(); altem.attachentity(new contactdetail {contactid = 1}); altem.attachentity(new contact {contactid = 1}); //use our helper method import our alternate em main 1 importall(altem, mainem); //verify navigations still working assert.aresame(contact, detail.contact); assert.aresame(detail, contact.contactdetail); //now similar import except we'll import dummy em before importing main em. // 'double import' seems cause problem. break if imported twice // main em. var dummy = new entitymanager(); importall(altem, dummy, mainem, mainem); //verify 1 time more. 1 pass ... assert.aresame(contact, detail.contact); //...but fail. contact detail in entity manager , can navigate related // contact...but reason, contact can't navigate detail longer. instead of // beingness expected contact detail entity, null entity assert.aresame(detail, contact.contactdetail); } //perhaps bit of odd way re-create entities between entity managers seems should // reasonable thing private static void importall(entitymanager source, params entitymanager[] destinations) { var ecs1 = source.cachestatemanager.getcachestate(); foreach (var destination in destinations) { destination.cachestatemanager.restorecachestate(ecs1, restorestrategy.normal); } } we running latest (as of writing) version of dev forcefulness 2012: 7.2.3.
the underlying problem here turned out issue how devforce works calls "unresolved parent" entities in 1:1 relationship. multiple imports / mutating entitycachestate issue reddish herring did expose problem.
this has been fixed in version 7.2.4.
c# silverlight devforce
Comments
Post a Comment