什么是 WCF RIA 服务?

我讨厌 MSDN 的 WCF RIA 服务站点。它不说它是什么,它只说它做什么。它说明了它可以实现什么,但没有说明我为什么需要它。

例如:

”在开发一个 N 层 RIA 解决方案正在协调 中间的应用程序逻辑 展示层”。

这对我来说没什么意义。

”RIA 服务解决这个问题的方法是 提供框架组件、工具、, 以及制作应用程序的服务 可用的服务器上的逻辑 RIA 客户端,而不需要您 手动复制那个程序 逻辑。您可以创建一个 RIA 客户端 意识到业务规则和 知道客户是自动 更新了最新的中间层逻辑 每次解决方案是 重新编译

那么它是否从服务器下载 DLL? 它是否是描述数据规则的元数据?

那是什么?它只是一个 VS 2010的 RAD 附加组件吗?或者它是 WCF 之上的一项技术,还是它之下的一项技术,还是什么?它住在哪里?用数据,用服务器,什么?

如果你能为我总结一下,我将不胜感激。

63708 次浏览

RIA services is a server-side technology that automatically generates client-side (Silverlight) objects that take care of the communication with the server for you and provide client-side validation.

The main object inside a RIA service is a DomainService, usually a LinqToEntitiesDomainService that is connected to a LinqToEntities model.

The key thing to remember in RIA services is that it's mainly a sophisticated build trick. When you create a domain service and compile your solution, a client-side representation of your domain service is generated. This client-side representation has the same interface. Suppose you create a server-side domain service CustomerService with a method IQueryable<Customer> GetCustomersByCountry. When you build your solution, a class is generated inside your Silverlight project called CustomerContext that has a method GetCustomersByCountryQuery. You can now use this method on the client as if you were calling it on the server.

Updates, inserts and deletes follow a different pattern. When you create a domain service, you can indicate whether you want to enable editing. The corresponding methods for update/insert/delete are then generated in the server-side domain service. However, the client-side part doesn't have these methods. What you have on your CustomerContext is a method called SubmitChanges. So how does this work:

  • For updates, you simply update properties of existing customers (that you retrieved via GetCustomersByCountryQuery).
  • For inserts, you use CustomerContext.Customers.Add(new Customer(...) {...}).
  • For deletes, you use CustomerContext.Customers.Remove(someCustomer).

When you're done editing, you call CustomerContext.SubmitChanges().

As for validation, you can decorate your server-side objects with validation attributes from the System.ComponentModel.DataAnnotations namespace. Again, when you build your project, validation code is now automatically generated for the corresponding client-side objects.

I hope this explanation helps you a little further.

The latest news: WCF RIA Services is dead:

http://blogs.msmvps.com/deborahk/who-moved-my-cheese-ria-services/

If you want to use RIA Services, they have been open sourced:

http://www.openriaservices.net/blog/posts/