Properties in WCF RIA Services – using LINQ-to-SQL

28 Feb

I have previously written a post about including properties in WCF RIA Services. The post was using POCO as business model. If you use LINQ-to-SQL as your business model you might need some extra load options to get your associated properties sent from the server to the client.

You can add the extra load options in the domain service methods on the server. In my previous post I use two entities; a Company and an Employee entity. The Company entity has a Employee property called CEO.

First you need to add a reference to System.Data.Linq and add a using in the BusinessService.

image

Second you need to add the load options. In this case you want CEO to be loaded when the Company is loaded.

image

Finally you set the load options to the DataContext and then you’re ready to return your data as normal.

image

(In the code above I get an error on the DataContext; don’t mind that – it’s just because I used the sample code from the previous post that don’t use LINQ-to-SQL and there don’t recognize the DataContext object.)

by xamlgeek

One Response to “Properties in WCF RIA Services – using LINQ-to-SQL”

  1. Viktor Larsson February 28, 2010 at 09:07 #

    Hello!
    Glad to see someone who’s kind of aligned with my technical interests.

    If you don’t mind, I’d like to share something with you I learned today about pasting code into WordPress. Have a look here:

    http://fragiledevelopment.wordpress.com/2010/02/28/how-to-post-code-to-wordpress

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

w

Connecting to %s

%d bloggers like this: