Using WCF RIA Services with your POCO, Part 5: Returning a POCO in another Assembly from the Domain Service

by mheydt 14. December 2009 01:18 >
In part 4 of this series I showed how to declare a POCO for use in RIA services, and how to use the object on the client.  In this post, I'll show how to use a class in another project/assembly.  Honestly, it's not very difficult at all.

As part of the SocialBus solution, I already has a User class defined in another project (SocialBus.Model).  This is a pretty straightforward class as-is:



A user in SocialBus is just a SocialBus specific user id, and a ServiceInfo object.  The ServiceInfo object is what is of real interest in SocialBus, as it will contains users and messages from various social networks (Twitter, Yammer, ...) that are mapped to this SocialBus user with the specified ID.  But for purposes of this example, it is only needed to be concerned with this User class.

To RIA enable this class, all I need to do as before is annotate the class, and all that is needed for now is to add a Key attribute:



This class is now ready to be used in the RIA services library.  All that is needed to be done is to add a reference to SocialBus.Model to SocialBus.RIA.Web, and to change the domain service to return an instance of this User class:



Now this service is very contrived and not of much use, but this is just for showing this example.  In another series of posts I will discuss connecting the domain service to LINQ to SQL, Twitter and Yammer; returning collections of objects; but like I said that's for another time.

The differences in this service model are really just in the using for the SocialBus.Model namespace, and in returning and instance of that object.  The client only changes slightly (besides there are no e-mail and username properties) is that I needed to add a 'using SocialBus.Model;' line.

That's it for this series.  There's a lot more that can be covered, but like I said those will be for another series of posts (that I'll do soon).



Tags:

RIA | Silverlight | SocialBus | WCF

blog comments powered by Disqus

about the author

I'm a .NET, XAML, and iOS polyglot that loves playing with new things and making cool and innovative stuff.  I am also a Mac junkie.

I am Principal Technologist for SunGard Global Services in NYC, in their Advanced Technologies practice, and I work extensively with SunGard's energy and financial customers.

Note the the posting on this blog are my own and do not represent the position, strategies or opinions of SGS.

twitter

I can't stop thinking big!
Sunday 1:08AM via WindowsLive
Just watched Moneyball. That's my pick for best movie this year.
Saturday 3:51PM via WindowsLive
@vincebelpiede: Report: Skype For Windows Phone Beta Imminent http://t.co/KYNjgg1L#mhtnd
Wednesday 8:39AM via Twitter for Mac
@mashable: Kinect Fusion Will Turn Gaming (and More) Into a 3D Fun House - http://t.co/Ihrq2fY2#mhtnd
Wednesday 8:39AM via Twitter for Mac
New Kinect SDK: http://t.co/57MvA5L5 #mhtnd
Wednesday 8:39AM via Twitter for Mac
Follow me on Twitter

recent comments

None

month list