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

Wow tonight's surfing has landed me on YouTube / rush / Exit Stage Left / Time to old school it! Wait, that was high school for me! LOL :)
Saturday 12:08AM via Microsoft
The Rise &Rise of the World's Biggest Cult Band http://t.co/emjoC4UL
Friday 8:49PM via Microsoft
I'm at Outback Steakhouse (Wilton, CT) w/ 2 others http://t.co/voxX9aNL
Friday 5:01PM via foursquare
@jeremylikness: Presentation patterns for #XAML based applications http://t.co/tl493BsR #wpf #Silverlight #windows8 #Metro #WinRT#mhtnd
Thursday 7:46AM via Twitter for Mac
I'm at Freepoint Commodities LLC (Greenwich, CT) http://t.co/ggTIcTGO
Monday 11:08AM via foursquare
Follow me on Twitter

recent comments

None

month list