Fast Serialization only serialize dirty entity?

Posts   
 
    
Barry
User
Posts: 232
Joined: 17-Aug-2005
# Posted on: 24-Aug-2007 09:08:31   

I found that when I assign value to field current value directly, the value is not serialized if I use fast serialization. Is it only serialize entity and fields marked as dirty?


SalesOrderEntity order = new SalesOrderEntity();
order.Fields["Currency"].CurrentValue = "USD";
return order;

Otis avatar
Otis
LLBLGen Pro Team
Posts: 39614
Joined: 17-Aug-2003
# Posted on: 24-Aug-2007 09:57:53   

That shouldn't happen. If you fetch an entity without setting any fields, are you able to serialize it? Our tests show that they are (so non-dirty entities are serialized)

Still, setting the CurrentValue property is not recommended.

Frans Bouma | Lead developer LLBLGen Pro
Barry
User
Posts: 232
Joined: 17-Aug-2005
# Posted on: 24-Aug-2007 10:13:46   

Entity can be serialized if I fetch it from database.

If I create an entity like the code in my last message, entity can also be serialized, but all value is null or default value after deserialized, the value I assigned to CurrentValue is not serialized. However, if I set IsDirty flag to true, it can serialize all values.

In some conditions, I want to ignore validation and field changed event, I assign value to CurrentValue directly.

Otis avatar
Otis
LLBLGen Pro Team
Posts: 39614
Joined: 17-Aug-2003
# Posted on: 24-Aug-2007 10:39:07   

I think if you set the state to Fetched (entity.Fields.State = EntityState.Fetched), it will work. I assume here that the code makes use of the entity state and packs the data accordingly: if the entity state is 'New', and no fields are changed, their data doesn't have to be sent over the wire, as they're not set anyway.

(We licensed the fast serialization code, so I have to look into the code to be sure, but I'm pretty sure it does this.)

Frans Bouma | Lead developer LLBLGen Pro
Otis avatar
Otis
LLBLGen Pro Team
Posts: 39614
Joined: 17-Aug-2003
# Posted on: 27-Aug-2007 14:05:52   

It indeed serializes the DbValue and not the CurrentValue if the entity isn't dirty, because it assumes the entity is either new (so both are null) or not new (so the data was fetched and DbValue contains the value from the db).

In a sense this is by design, as it attempts to compact the data as much as possible, and it has to work with fixed blocks, so it can't write for one field both values and for another field just the DbValue.

Frans Bouma | Lead developer LLBLGen Pro
AmitayD
User
Posts: 45
Joined: 22-Aug-2007
# Posted on: 05-Sep-2007 16:02:27   

Hi, not sure if it's hijacking the thread, but it's a similiar problem.

I'm encountering a s similiar problem when xml serializing through WCF: I return an entity with a related entity collection (inside a Data contract, but i don't think it should matter), from the server to the client, which is going through fine. Then i return the the entity and relation entity collection back to the server, it goes fine, and the server see the complete entity collection. **However, ** if i make a change only to one of the related entities, and send the entity back to the server, though the related entities exist in the request XML, they are not shown on the enitity.relatedEntitiesCollection. I think it has something to do with the Compact25 serialization, any way to revert to the verbose serialization over WCF?

i'm attaching the two request XMLs that are sent from the client to the server (that was originally got from the server). The entity is "PracticeEntity" and the related Entities are "PracticeInsuranceCarrierEntity"

Sent to the service without changing data in PracticeInsuranceCarriers: _ [System.ServiceModel.Channels.BufferedMessage]: {<s:Envelope xmlns:s="http://schemas.xmlsoap.org/soap/envelope/"> <s:Header> <RequestContext xmlns="http://ewave.PMDS/" xmlns:i="http://www.w3.org/2001/XMLSchema-instance"> <OracleTimeZoneID xmlns="http://ewave.PMDS.Server.DataContracts/2007/08">America/New_York</OracleTimeZoneID> <LanguageName xmlns="http://ewave.PMDS.Server.DataContracts/2007/08">en-US</LanguageName> <DelemiterLine xmlns="http://ewave.PMDS.Server.DataContracts/2007/08"><BR></DelemiterLine> <UserLoginID xmlns="http://ewave.PMDS.Server.DataContracts/2007/08">-1</UserLoginID> <UserLoginName xmlns="http://ewave.PMDS.Server.DataContracts/2007/08">TestAmitay</UserLoginName> <PracticeID xmlns="http://ewave.PMDS.Server.DataContracts/2007/08">0</PracticeID> </RequestContext> <To s:mustUnderstand="1" xmlns="http://schemas.microsoft.com/ws/2005/05/addressing/none">[http://c279.ewave.co.il/ewave.WCF.PMDS.Service/PracticeManagementService.svc](http://c279.ewave.co.il/ewave.WCF.PMDS.Service/PracticeManagementService.svc)</To> <Action s:mustUnderstand="1" xmlns="http://schemas.microsoft.com/ws/2005/05/addressing/none">UpdatePracticeManagementInfo</Action> </s:Header> <s:Body> <UpdatePracticeManagementInfo xmlns="http://ewave.PMDS.Server.ServiceContracts/2007/09"> <dcPracticeManagement xmlns:a="http://ewave.PMDS.Server.DataContracts/2007/08" xmlns:i="http://www.w3.org/2001/XMLSchema-instance"> <astuck_out_tongue_winking_eye ractice> <PracticeEntity ObjectID="4163a578-aa02-4cba-ad6f-16bd0d47f643" Format="Compact25"> <PracticeId>0</PracticeId> <PracticeName>No more tests!tyty</PracticeName> <Address>Ben Yehuda 60</Address> <LockUserCount>3</LockUserCount> <PracticeInsuranceCarrierCollection> <PracticeInsuranceCarrierEntity ObjectID="98efbc0c-bd16-49a6-a132-e1655ccd8309"> <PracticeInsuranceCarrierId>6</PracticeInsuranceCarrierId> <PracticeId>0</PracticeId> <InsuranceTypeId>1</InsuranceTypeId> <InsuranceName>bla</InsuranceName> <Address>bla bla</Address> <Phone>33535 </Phone> <PracticeByPracticeId Ref="4163a578-aa02-4cba-ad6f-16bd0d47f643" /> <_lps fs="AKiiCg==" es="1" /> </PracticeInsuranceCarrierEntity> <PracticeInsuranceCarrierEntity ObjectID="fccba3dd-a23a-4866-b78b-0f260d7a57ee"> <PracticeInsuranceCarrierId>3</PracticeInsuranceCarrierId> <PracticeId>0</PracticeId> <InsuranceTypeId>1</InsuranceTypeId> <InsuranceName>Insurance name</InsuranceName> <Address>bla bla</Address> <Phone>123 </Phone> <PracticeByPracticeId Ref="4163a578-aa02-4cba-ad6f-16bd0d47f643" /> <_lps fs="AKiiCg==" es="1" /> </PracticeInsuranceCarrierEntity> <PracticeInsuranceCarrierEntity ObjectID="f6eea311-9d77-4be5-b9cf-0ffabc910190"> <PracticeInsuranceCarrierId>5</PracticeInsuranceCarrierId> <PracticeId>0</PracticeId> <InsuranceTypeId>1</InsuranceTypeId> <InsuranceName>Insurance three</InsuranceName> <Address>bla bla</Address> <Phone>3455 </Phone> <PracticeByPracticeId Ref="4163a578-aa02-4cba-ad6f-16bd0d47f643" /> <_lps fs="AKiiCg==" es="1" /> </PracticeInsuranceCarrierEntity> <PracticeInsuranceCarrierEntity ObjectID="ab2a7729-5bdb-4be0-8d52-855692eec017"> <PracticeInsuranceCarrierId>4</PracticeInsuranceCarrierId> <PracticeId>0</PracticeId> <InsuranceTypeId>1</InsuranceTypeId> <InsuranceName>Insurance two</InsuranceName> <Address>bla bla</Address> <Phone>2345 </Phone> <PracticeByPracticeId Ref="4163a578-aa02-4cba-ad6f-16bd0d47f643" /> <_lps fs="AKiiCg==" es="1" /> </PracticeInsuranceCarrierEntity> <_lps f="7" /> </PracticeInsuranceCarrierCollection> <_lps fs="GKqqKqoq" es="1"> <dbv /> </_lps> </PracticeEntity> </astuck_out_tongue_winking_eye ractice> </dcPracticeManagement> </UpdatePracticeManagementInfo> </s:Body> </s:Envelope>}_

after changing one of the PracticeInsuranceCarriers name to "damn": with change

</s:Envelope>} [System.ServiceModel.Channels.BufferedMessage]: {<s:Envelope xmlns:s="http://schemas.xmlsoap.org/soap/envelope/"> <s:Header> <RequestContext xmlns="http://ewave.PMDS/" xmlns:i="http://www.w3.org/2001/XMLSchema-instance"> <OracleTimeZoneID xmlns="http://ewave.PMDS.Server.DataContracts/2007/08">America/New_York</OracleTimeZoneID> <LanguageName xmlns="http://ewave.PMDS.Server.DataContracts/2007/08">en-US</LanguageName> <DelemiterLine xmlns="http://ewave.PMDS.Server.DataContracts/2007/08"><BR></DelemiterLine> <UserLoginID xmlns="http://ewave.PMDS.Server.DataContracts/2007/08">-1</UserLoginID> <UserLoginName xmlns="http://ewave.PMDS.Server.DataContracts/2007/08">TestAmitay</UserLoginName> <PracticeID xmlns="http://ewave.PMDS.Server.DataContracts/2007/08">0</PracticeID> </RequestContext> <To s:mustUnderstand="1" xmlns="http://schemas.microsoft.com/ws/2005/05/addressing/none">[http://c279.ewave.co.il/ewave.WCF.PMDS.Service/PracticeManagementService.svc](http://c279.ewave.co.il/ewave.WCF.PMDS.Service/PracticeManagementService.svc)</To> <Action s:mustUnderstand="1" xmlns="http://schemas.microsoft.com/ws/2005/05/addressing/none">UpdatePracticeManagementInfo</Action> </s:Header> <s:Body> <UpdatePracticeManagementInfo xmlns="http://ewave.PMDS.Server.ServiceContracts/2007/09"> <dcPracticeManagement xmlns:a="http://ewave.PMDS.Server.DataContracts/2007/08" xmlns:i="http://www.w3.org/2001/XMLSchema-instance"> <astuck_out_tongue_winking_eye ractice> <PracticeEntity ObjectID="4163a578-aa02-4cba-ad6f-16bd0d47f643" Format="Compact25"> <PracticeId>0</PracticeId> <PracticeName>No more tests!tyty</PracticeName> <Address>Ben Yehuda 60</Address> <LockUserCount>3</LockUserCount> <PracticeInsuranceCarrierCollection> <PracticeInsuranceCarrierEntity ObjectID="98efbc0c-bd16-49a6-a132-e1655ccd8309"> <PracticeInsuranceCarrierId>6</PracticeInsuranceCarrierId> <PracticeId>0</PracticeId> <InsuranceTypeId>1</InsuranceTypeId> <InsuranceName>damn</InsuranceName> <Address>bla bla</Address> <Phone>33535 </Phone> <PracticeByPracticeId Ref="4163a578-aa02-4cba-ad6f-16bd0d47f643" /> <_lps fs="QKiiCg==" es="1"> <dbv /> </_lps> </PracticeInsuranceCarrierEntity> <PracticeInsuranceCarrierEntity ObjectID="fccba3dd-a23a-4866-b78b-0f260d7a57ee"> <PracticeInsuranceCarrierId>3</PracticeInsuranceCarrierId> <PracticeId>0</PracticeId> <InsuranceTypeId>1</InsuranceTypeId> <InsuranceName>Insurance name</InsuranceName> <Address>bla bla</Address> <Phone>123 </Phone> <PracticeByPracticeId Ref="4163a578-aa02-4cba-ad6f-16bd0d47f643" /> <_lps fs="AKiiCg==" es="1" /> </PracticeInsuranceCarrierEntity> <PracticeInsuranceCarrierEntity ObjectID="f6eea311-9d77-4be5-b9cf-0ffabc910190"> <PracticeInsuranceCarrierId>5</PracticeInsuranceCarrierId> <PracticeId>0</PracticeId> <InsuranceTypeId>1</InsuranceTypeId> <InsuranceName>Insurance three</InsuranceName> <Address>bla bla</Address> <Phone>3455 </Phone> <PracticeByPracticeId Ref="4163a578-aa02-4cba-ad6f-16bd0d47f643" /> <_lps fs="AKiiCg==" es="1" /> </PracticeInsuranceCarrierEntity> <PracticeInsuranceCarrierEntity ObjectID="ab2a7729-5bdb-4be0-8d52-855692eec017"> <PracticeInsuranceCarrierId>4</PracticeInsuranceCarrierId> <PracticeId>0</PracticeId> <InsuranceTypeId>1</InsuranceTypeId> <InsuranceName>Insurance two</InsuranceName> <Address>bla bla</Address> <Phone>2345 </Phone> <PracticeByPracticeId Ref="4163a578-aa02-4cba-ad6f-16bd0d47f643" /> <_lps fs="AKiiCg==" es="1" /> </PracticeInsuranceCarrierEntity> <_lps f="7" /> </PracticeInsuranceCarrierCollection> <_lps fs="GKqqKqoq" es="1"> <dbv /> </_lps> </PracticeEntity> </astuck_out_tongue_winking_eye ractice> </dcPracticeManagement> </UpdatePracticeManagementInfo> </s:Body> </s:Envelope>}

Note the difference: <_lps fs="QKiiCg==" es="1"> instead of <_lps fs="AKiiCg==" es="1" /> . What does that mean?

thanks, Amitay

Walaa avatar
Walaa
Support Team
Posts: 14950
Joined: 21-Aug-2005
# Posted on: 05-Sep-2007 16:21:00   

Hi, not sure if it's hijacking the thread, but it's a similiar problem.

Please create a new thread, I'm gonna close this one.

As the XML outputs look good to me. I can't guess why the changed related entities don't show on the they are not shown on the enitity.relatedEntitiesCollection So please post the server and client code snippets. Also post the LLBLGen Pro runtime library version.