Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What are the pitfalls of using .NET RIA Services in Silverlight?

Silverlight can use WCF, Web Services, REST based services, .NET RIA Services, but it seems like Silverlight and .NET RIA Services are preferred most.

I want to know if there are any common issues [which can be a show stopper if one goes ahead with this combo] that you have seen in practical implementation of SL with .NET RIA Services.

Thanks, Rahul

like image 237
Rahul Soni Avatar asked Sep 30 '10 15:09

Rahul Soni


People also ask

What is wcf ria service?

WCF RIA Service is a higher-level framework and a new component of frameworks like . NET 4 and Silverlight 4 that eases the procedure of building a complex business application in Silverlight by offering client-side validation. RIA stands for Rich Internet Applications.

What is WCF RIA Services v1 0 sp2?

The WCF RIA Services is a framework that provides a pattern to write application logic that runs on the mid-tier and controls access to data for queries, changes and custom.


4 Answers

Working with metadata (and writing it by yourself) is really pain in the ass. Especially when you need to update your model. RIA tutorial applications look quite well on a small database but working with a model consisting of dozens of entites, you'll spend more time updating metadata than programming the application itself. This is also connected with definition of validation and all the validation and description messages on properties from resources. But we have created some T4 templates so it all gets generated automatically.

On the other hand, we're using RIA on two projects and I must say it's the best we can get. We had some troubles with validation but it can be solved (validating before checking whether the property value has changed). And once you are aware of memory management with RIA (you don't want to load the whole databse into memory on client etc.), it can be used in real life.

Unfortunately, there is no silver bullet, so if you, for example, plan other clients than your SL app to connect to the server, you should probably watch somewhere else (WCP Data Services, maybe?). Or if you don't want to update data from your client, I see RIA as overkill.

like image 124
gius Avatar answered Oct 19 '22 08:10

gius


FOLLOWING MY PREVIOUS ANSWER HERE THE DISADVANTAGES OF RIA SERVICES: On the other end the disadvantage of ria services is its lack of flexibility. Mainly it is like a tube that connect a class on the server side with its client side representative in such a way you operate on the client side class like you were operating directly on the server side class. If the way this "tube" his handled is ok for your application, you get a lot of services fro free (without writing any code...). However, there are limitations that one cannot remove specifically:

1) You have not the same freedom in defining behavior, attribute etc. to modify the way the Web service behaves. For instance you cannot define a distributed transaction involving more than one web service. It is difficult to add new endpoints....You have to write code....not simply modifying a configuration file.

2) You can only define one Insert/one update/one get methods for each class. If you apply filtering to the client side query via LINQ it is applied only on the client, i.e. all data are downloaded from server and then filtered on the client. On the contrary if you use a WCF data services based on OData and you define a query on the client side. THIS QUERY IS TRANSLATED INTO A REST QUERY (a query encoded in the URL of the request) THEREFORE ONLY THE DATA YOU REQUIRE WITH YOUR FILTER ARE ACTUALLY DOWNLOADED FROM THE SERVER. For more information on WCF data service see here.

3) By contrast with WCF Data Services you have no Validation service offered as with Ria service. However you can continue using data annotatios with the help of my Validation Toolkit for WPF & Silverlight, that is available for free here

like image 40
Francesco Abbruzzese Avatar answered Oct 19 '22 08:10

Francesco Abbruzzese


I've been using RIA-Services for a few months and a couple of differen apps and found that I can get it to do pretty much everything I need. It saves you a LOT of time by using clever code-generation to take care of a lot of the plumbing.

It is best used if you're creating a straight forward CRUD application using EF, if that is the case then you should be fine.

If you're doing something a little different then it take a little bit more work but it still is (in my opinion) the best option for getting data to your silverlight client. There are some small annoyances but no show stoppers that I've found.

For example, I've used it with SQL Credentials (user logs into Silverlight app using their SQL login and I dynamically create connection string using the username + password). This took a little bit more work but it works fine.

I've also used it to return data to the client from Stored Procedures rather than from Entities, again this takes a bit more work but it works fine.

like image 1
Fermin Avatar answered Oct 19 '22 10:10

Fermin


Ria services are created just to be used with Silverlight. They are substantially a standard "package" ready to be used by Silverlight. The advantage is that you have a lot of services without need to write code i.e.:

  1. Support for data annotations
  2. Support for membership provider and login
  3. Support for transferring to silverlight server side generated exceptions. There is a difficulty in silverlight that make difficultthe normal error transfer of exception through FaultContract. The point is that the browser is not able to handle all error codes. Ria services solve this with a trick

All things done by Ria can be done with WCF and with other available software and in particular with Wcf data services. For instance for data annotations I found this library that do a better job than Ria services, support for membership just require activating the already existing membership endpoint of a WCF service, and finally the exception problem is easily resolved by writing a WCF behaviour. Code is available here:http://www.silverlightshow.net/Storage/10Tips.zip The point is that with Ria Service you have all this in a mouse click!. On the other side Ria Services are really difficult to customize...so if you don't like the standard solution they offer you simply can't use them

like image 1
JDick Avatar answered Oct 19 '22 10:10

JDick