New Posts New Posts RSS Feed: Silverlight - Cannot Coerce
  FAQ FAQ  Forum Search   Calendar   Register Register  Login Login

Silverlight - Cannot Coerce

 Post Reply Post Reply
Author
jipock View Drop Down
Newbie
Newbie
Avatar

Joined: 08-Dec-2010
Location: Cherry Hill, NJ
Posts: 39
Post Options Post Options   Quote jipock Quote  Post ReplyReply Direct Link To This Post Topic: Silverlight - Cannot Coerce
    Posted: 14-Dec-2010 at 1:50pm
Good Evening,
 
I'm trying to edit an entity that I've created and am getting a "Cannot Coerce...." error.
 
Specifically,I have an object (say, a car) that contains an object (Engine). I'm loading this from the database without any errors. But, I want to 'click a button and select a new engine from a child window and put this selected engine into the engine property of the car (and essentially removing the original engine).  My code looks like this:
 

if (box.DialogResult == true){

_model.CurrentCar.EngineId = box.SelectedEngine.EngineID;

_model.CurrentCar.Engine = box.SelectedEngine; }

To confirm - the Engine and Selected Engine are the same IdeaBlade entity object type (just different instantiations).
 
The Error message is: "Unable to construct a PropertyInterceptorAction for method: BeforeSetAnyProperty' in type 'Namespace.Engine' Cannot coerce IdeaBlade.EntityeModel.NavigationEntityPropertySetInterceptorsArgs..."
 
 
Any suggestions where to look for an answer?
Back to Top
kimj View Drop Down
IdeaBlade
IdeaBlade
Avatar

Joined: 09-May-2007
Posts: 1391
Post Options Post Options   Quote kimj Quote  Post ReplyReply Direct Link To This Post Posted: 17-Dec-2010 at 7:23pm
The arguments to the BeforeSetAnyProperty property interceptor need to be less specific.  Since the interceptor will be called before setting any property on the entity, the arguments need to be suitable for any property type.  There are a number of different arguments which will work, a few would be:
 
  BeforeSetAnyProperty(IPropertyInterceptorArgs args)
 
  BeforeSetAnyProperty(PropertyInterceptorArgs<Engine, object> args)
 
Check out the BeforeSetAttribute in the DevForce Help Reference installed with the product for more possibilities.
Back to Top
jipock View Drop Down
Newbie
Newbie
Avatar

Joined: 08-Dec-2010
Location: Cherry Hill, NJ
Posts: 39
Post Options Post Options   Quote jipock Quote  Post ReplyReply Direct Link To This Post Posted: 20-Dec-2010 at 6:47am

(Hitting myself on the head at the answer)... 

It's working now. Thank you!
 
 
 
 
Back to Top
 Post Reply Post Reply

Forum Jump Forum Permissions View Drop Down