silverlight 4.0 - Save a foreign key, but not the whole object in WCF Data Services -


i'm using silverlight 4, entity framework 4 , wcf data services. have playlist object. playlist object has properties , foreign key represented 0 1 navigation property display object. in database there display_id column.

i'm trying save playlist , setting display_id directly, without loading whole display object database (i display id query string). i've tried :

playlist.display = new display() { id = 3136 }; // setlink throws exception display not yet tracked     context.setlink(playlist.display, "display", playlist); // or i've tried, error: entities in 'edm.displays' participate in //'displayx' relationship. 0 related 'x' found. 1 'x' expected context.addtodisplays(playlist.display); context.setlink(playlist, "display", playlist.display); 

do need change edm or there way on client side?

first of need attach object objectset

display d = new display{ id = 3136 }; context.displays.attach(d); 

it executed locally without calling database, , can work need

there way: object playlist contains object dysplayreference property entitykey if it's null create it, else replace key in entitykeyvalues


Comments

Popular posts from this blog

asp.net - repeatedly call AddImageUrl(url) to assemble pdf document -

java - Android recognize cell phone with keyboard or not? -

iphone - How would you achieve a LED Scrolling effect? -