Showing results for 
Search instead for 
Do you mean 
Community Home Request Access Read Blogs Share Your Ideas Search Community View My Settings
Reply
Copper Super Contributor
Posts: 20
Registered: ‎10-10-2012

Accessing entity object via sdata payload

 

tried below and failed to cast,

SDataPayload contactPayLoad = (SDataPayload)payLoad.Values["Contact"];
IContact contact = (Sage.Entity.Interfaces.IContact)contactPayLoad;

 

 Accessing an entity object via sdata payload could we do that ? Smiley Happy

Bronze Super Contributor
Posts: 152
Registered: ‎02-01-2011

Re: Accessing entity object via sdata payload

Why not just use:

 

IContact contact = Sage.Platform.EntityFactory.GetById<IContact>(payLoad.Key);

 

Andy Freeman
TrellisPoint, LLC
Copper Super Contributor
Posts: 20
Registered: ‎10-10-2012

Re: Accessing entity object via sdata payload

Thanks for the feedback @greensweater, however

what I learnt recently you wont be able to use entiyfactor unless you are not within the application.

 

(entity factory cannot be accessed via sdata)

 

so this wont work:

IContact contact = Sage.Platform.EntityFactory.GetById<IContact>(payLoad.Key);
Bronze Super Contributor
Posts: 152
Registered: ‎02-01-2011

Re: Accessing entity object via sdata payload

You're trying to instantiate a contact entity (Sage.Entity.Interfaces.IContact). An SData payload is basically a JSON wrapper. You won't be able to cast that to an NHibernate entity object. If you want to instantiate an IContact you'll need the same ORM library that contains EntityFactory (Sage.Platform.dll) so I'm not sure what you mean that you can't access EntityFactory.

 

I may be able to better help you with more details on what you're trying to do.

Andy Freeman
TrellisPoint, LLC