简体   繁体   English

什么是WCF RIA服务?

[英]What is WCF RIA services?

I hate MSDN's site for WCF RIA services. 我讨厌MSDN的WCF RIA服务网站。 It does not say what it is, it only says what it does. 它没有说它是什么,它只说它做了什么。 It says what it can achieve but does not say why I need it. 它说它可以实现什么但不说我为什么需要它。

For example: 例如:

"A common problem when developing an n-tier RIA solution is coordinating application logic between the middle tier and the presentation tier". “开发n层RIA解决方案时的一个常见问题是协调中间层和表示层之间的应用程序逻辑”。

Well, it does not mean much to me. 嗯,这对我来说意义不大。

"RIA Services solves this problem by providing framework components, tools, and services that make the application logic on the server available to the RIA client without requiring you to manually duplicate that programming logic. You can create a RIA client that is aware of business rules and know that the client is automatically updated with latest middle tier logic every time that the solution is re-compiled." “RIA Services通过提供框架组件,工具和服务来解决这个问题,这些组件,工具和服务使RIA客户端可以使用服务器上的应用程序逻辑,而无需手动复制该编程逻辑。您可以创建一个了解业务规则的RIA客户端并且知道每次重新编译解决方案时,客户端都会自动使用最新的中间层逻辑进行更新。“

So does it download DLLs from server? 那么从服务器下载DLL? Is it a metadata describing the rules for the data? 它是描述数据规则的元数据吗?

So what is it? 那是什么? Is it just a VS 2010 add-on for RAD? 它只是RAD的VS 2010附加组件吗? Or is it a technology on top of WCF or underneath it or what? 或者它是WCF之上或其下的技术还是什么? Where does it live? 它在哪里生活? With data, with server, what? 有了数据,还有服务器,什么?

I appreciate if you can summarise this for me please. 如果你能为我总结一下,我很感激。

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. RIA服务是一种服务器端技术,可自动生成客户端(Silverlight)对象,负责与您的服务器通信并提供客户端验证。

The main object inside a RIA service is a DomainService , usually a LinqToEntitiesDomainService that is connected to a LinqToEntities model. 一个RIA服务的内部的主要对象是一个DomainService ,通常是LinqToEntitiesDomainService连接到一个LinqToEntities模型。

The key thing to remember in RIA services is that it's mainly a sophisticated build trick. 在RIA服务中要记住的关键是它主要是一个复杂的构建技巧。 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 . 假设您使用IQueryable<Customer> GetCustomersByCountry方法创建服务器端域服务CustomerService When you build your solution, a class is generated inside your Silverlight project called CustomerContext that has a method GetCustomersByCountryQuery . 构建解决方案时,会在Silverlight项目中生成一个名为CustomerContext的类,该类具有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 . 您在CustomerContext是一种名为SubmitChanges的方法。 So how does this work: 那么这是如何工作的:

  • For updates, you simply update properties of existing customers (that you retrieved via GetCustomersByCountryQuery ). 对于更新,您只需更新现有客户的属性(通过GetCustomersByCountryQuery检索)。
  • For inserts, you use CustomerContext.Customers.Add(new Customer(...) {...}) . 对于插入,您使用CustomerContext.Customers.Add(new Customer(...) {...})
  • For deletes, you use CustomerContext.Customers.Remove(someCustomer) . 对于删除,使用CustomerContext.Customers.Remove(someCustomer)

When you're done editing, you call CustomerContext.SubmitChanges() . 完成编辑后,调用CustomerContext.SubmitChanges()

As for validation, you can decorate your server-side objects with validation attributes from the System.ComponentModel.DataAnnotations namespace. 对于验证,您可以使用System.ComponentModel.DataAnnotations命名空间中的验证属性来装饰服务器端对象。 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: 最新消息:WCF RIA服务已经死亡:

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

If you want to use RIA Services, they have been open sourced: 如果您想使用RIA服务,它们是开源的:

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

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM