C# 结合 WPF + WCF + 实体框架的好例子
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/10806081/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Good example of combining WPF + WCF + Entity Framework
提问by Trevor Elliott
I am planning on creating a new data-driven Client/Server application with the flexibility to have WPF, Silverlight, and mobile clients. I am already well versed in WPF and need to learn how to implement the back end. Everything I've read is pointing me toward using WCF + Entity Framework.
我计划创建一个新的数据驱动的客户端/服务器应用程序,可以灵活地使用 WPF、Silverlight 和移动客户端。我已经精通WPF,需要学习如何实现后端。我读过的所有内容都指向我使用 WCF + 实体框架。
I have yet to find a realistic example of combining these three technologies. I want to use WPF's databinding to be able to easily bind to database objects in a way that avoids as much procedural code as possible.
我还没有找到结合这三种技术的现实例子。我想使用 WPF 的数据绑定,以便能够以尽可能避免过程代码的方式轻松绑定到数据库对象。
I looked at thisexample based on Prism but it looks like it was never finished, it doesn't really do anything, it's basically a glorified "Hello World!"
我查看了这个基于 Prism 的示例,但看起来它从未完成,它并没有真正做任何事情,它基本上是一个美化的“Hello World!”
采纳答案by Trevor Elliott
I have done some digging and this is what I've found:
我做了一些挖掘,这就是我发现的:
Karl Shifflett's Netflix Stuff Application(WPF, MVVM, Data Services)
Karl Shifflett 的 Netflix Stuff 应用程序(WPF、MVVM、数据服务)
IssueVision(Silverlight, MVVM, WCF RIA Services, Entity Data Model)
IssueVision(Silverlight、MVVM、WCF RIA 服务、实体数据模型)
回答by AvkashChauhan
Have you looked at the walk through below which just include WPF + WCF + Entity Framework only:
您是否看过下面的演练,其中仅包含 WPF + WCF + 实体框架:
http://msdn.microsoft.com/en-us/library/dd465161.aspx
http://msdn.microsoft.com/en-us/library/dd465161.aspx
In this walkthrough, you will create a WPF application that contains data-bound controls. The controls are bound to customer records that are encapsulated in a WCF Data Service. You will also add buttons that customers can use to view and update records.
在本演练中,您将创建一个包含数据绑定控件的 WPF 应用程序。这些控件绑定到封装在 WCF 数据服务中的客户记录。您还将添加客户可用于查看和更新记录的按钮。
This walkthrough illustrates the following tasks:
本演练说明了以下任务:
- Creating an Entity Data Model that is generated from data in the AdventureWorksLT sample database.
- Creating a WCF Data Service that exposes the data in the Entity Data Model to a WPF application.
- Creating a set of data-bound controls by dragging items from the Data Sources window to the WPF designer.
- Creating buttons that navigate forward and backward through customer records.
- Creating a button that saves changes to data in the controls to the WCF Data Service and the underlying data source.
- 创建从 AdventureWorksLT 示例数据库中的数据生成的实体数据模型。
- 创建一个 WCF 数据服务,将实体数据模型中的数据公开给 WPF 应用程序。
- 通过将项目从“数据源”窗口拖到 WPF 设计器来创建一组数据绑定控件。
- 创建在客户记录中向前和向后导航的按钮。
- 创建一个按钮,将控件中的数据更改保存到 WCF 数据服务和基础数据源。
回答by alextansc
Assuming you are using Visual Studio 2010, then it might be worth your time to look at WCF Data Services. Here's an article about it:
假设您使用的是 Visual Studio 2010,那么可能值得您花时间查看 WCF 数据服务。这是一篇关于它的文章:
Entity Framework 4.0 and WCF Data Services 4.0 in Visual Studio 2010
Visual Studio 2010 中的实体框架 4.0 和 WCF 数据服务 4.0
The article also has a link to a code sample, but I'm not familiar with Silverlight and unable to run it yet.
这篇文章还有一个代码示例的链接,但我对 Silverlight 不熟悉,还无法运行它。
回答by huoxudong125
Demonstrates WPF, MVVM, WCF, WF and Entity Framework 6.0maybe a good demo for you. and there are other Layered Architecture Samples.
演示 WPF、MVVM、WCF、WF 和 Entity Framework 6.0对您来说可能是一个很好的演示。还有其他分层架构示例。
回答by Amir Twito
I manage to connect my WPF application using the following examples:
我设法使用以下示例连接我的 WPF 应用程序:
Getting Started with WCF (Windows Communication Foundation) – Running and Debugging Quickly -https://blogs.msdn.microsoft.com/brunoterkaly/2013/10/18/getting-started-with-wcf-windows-communication-foundation-running-and-debugging-quickly/
WCF(Windows 通信基础)入门 - 快速运行和调试 - https://blogs.msdn.microsoft.com/brunoterkaly/2013/10/18/getting-started-with-wcf-windows-communication-foundation-running -和-调试-快速/
WCF Programming – How to write a client app that connects to a WCF Service https://blogs.msdn.microsoft.com/brunoterkaly/2013/10/28/wcf-programming-how-to-write-a-client-app-that-connects-to-a-wcf-service/
WCF 编程 - 如何编写连接到 WCF 服务的客户端应用程序 https://blogs.msdn.microsoft.com/brunoterkaly/2013/10/28/wcf-programming-how-to-write-a-client-app -that-connects-to-a-wcf-service/

