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

后端 未结 8 1821
醉酒成梦
醉酒成梦 2021-02-08 02:04

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

相关标签:
8条回答
  • 2021-02-08 02:28

    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

    0 讨论(0)
  • 2021-02-08 02:35

    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.

    0 讨论(0)
  • 2021-02-08 02:41

    I am really disappointed about MS. As it is obvious from the discussion about this topic, I am not the only one who sometimes gets confused by all the "tools" we are provided by MS. The problem is that really miss some managing and coordination from MS.

    The result is that there are very similar products with similar functionality where one does one thing better and the other another one. And no one can tell which one is better to use or even which one will be supported in the next version.

    I have two examples.

    1. Entity Framework vs. Linq to SQL in .net 3.5 These were very similar, both did the same. L2S was meant to be better for smaller projects, EF for enterprise ones. L2S had much better designer and better LINQ implementation. EF was supposed to be able to map more database tables to one entity but this never worked really well. And, by the way, even EF4 does not have a very useful feature of L2S that is AssociateWith<> function. And suddenly, L2S is no longer supported and everyone should use EF. There should be someone who at the very beginning said "Stop, we have two similar technologies. Let get the two teams together and make one product with the best of both.".

    2. RIA services vs. WCF Data services Again, the same problem. Two distinct teams working on two similar products. Both with some better features tham the other. But definitely, there could be one product with the features of both.

    How should we decide which one to use (besides spending a lot of time to mastering both)? Which one will be deprecated?

    ...this is probably for a blog post, not answer here. Sorry, I just needed to write it somewhere and since there was a lot of talk about these issues, it seemed as a proper place. I will definitely try to blog about it later.

    0 讨论(0)
  • 2021-02-08 02:46

    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

    0 讨论(0)
  • 2021-02-08 02:46

    Ria services and rest services offers a quite similar access to server side classes that often are entity framework classes(but not necessarely...as several programmers appears to belive). The main advantage of Ria Services is that they handles Validation by using Data Annotations on server-side classes and do it in a smart way: they automatically generate client side-classes with the same data-annotations and validate them by implementing automatically INotifyDataError on the client-side class. If one uses custom attributes and put the.shared.cs (or .vb) extension those attribute definitions are copied in the silverlight client and used in the client-side validation, otherwise they are used only to perform server-side validation......for more information pls see my blog post

    here

    0 讨论(0)
  • 2021-02-08 02:46

    I have been using SL4 + EF for our enterprise development and I found it, it is hard to develop with EF if you go with the default out of box development model. What I mean by that is, any screen you develop, for the data you use EF with a table/view then very quickly the your model get blotted. After adding 20 new pages with 6 to 10 tables/views now it is very difficult to add entities in the edmx. I personally do not like the blotting. If you see some of the questions I have asked and based on the answers it seems for enterprise level development do not use stright out of the box EF features instead, create a domain model using POCO with PI and then use that to develop your application. I have not completed one successfully yet so I do not have personal result on this. One another thing, I noticed it is not related EF per se instead SL itself. Spend some time and understand either PRISM/MEF/Caliburn and use that create your application. One of the problem I do not like in SL is testability, even though SL unit testing is there, it itself is not a good unit testing framework. Also testing EF is not breeze either. With PRISM/MEF/Caliburn not only testing is easy and also your development will be truly modular. So before you start your development, my recommendation is to look at one of the framework and instead of using EF outof box, use POCO to create your domain model and then use POCO to use it in SL. Hope this helps.

    0 讨论(0)
提交回复
热议问题