<?xml version="1.0" encoding="utf-8"?>
<rss version="2.0">
<channel>
<title>软件下载资讯 | 遗昕传媒（伴随着您成长 伴随着您进步）- weisim3.com</title>
<link>https://www.weisim3.com/Download</link>
<description>桌面软件包含的科目：WinForm、WPF、JavaFX</description>
<language>UTF-8</language>
<ttl>60</ttl>
<copyright>Copyright (C) 2007 - 2026 遺昕 | Weisim3.com, All Rights Reserved.</copyright>
<item>
<title>WPF与WebApi数据交互基础</title>
<category>WPF</category>
<downloadNum>15362</downloadNum>
<link><![CDATA[https://www.weisim3.com/Download?Id=166&CD=10&Date=20240806-20-05-03&Subject=39&S=/Null/]]></link>
<description><![CDATA[WPF的数据源可以WebService或WCF也可以是WebApi，也可以直接连接数据库读取数据，WebService或WCF以及WebApi是绕开直接连接数据库通过Api接口应用程序操作数据。而WebApi提供了两种数据输出格式xml和json，本文演示“WPF与WebApi数据交互基础”，开发者需要对WPF项目基本的入门，以及ASP.NET的WebApi项目有基本的了解，本文不会全面展开介绍这两种项目基础，需要有大致了解后可以迅速上手本文的示例。第一步：创建WPF项目，在Visual Studio中新建，选择项目类型“Windows 桌面”，再选择“WPF 应用”项目名称命名为“WebApiCall”，项目路径位置，根据情况选择盘符路径，框架版本：选择.NET FrameWork 4.7，点击确定创建了WPF项目，如下图：创建完WPF项目后，默认建立了窗体MainWindow.xaml，后面读取操作WebApi数据就在默认的窗体中完成，WPF应用程序的准备工作已经就绪。第二步：创建ASP.NET WebApi应用程序，同样在Visual Studio中新建项目，选择Web类型，选择ASP.NET Web应用程序，项目名命名为“CustomersManager”,框架版本：同样选择.NET   FrameWork   4.7,应用程序类型：选择Web API，添加文件夹和核心引用，选择MVC和Web API。如下图：WebApi项目创建之后，在Models文件目录中新建Customer和CustomerCenter类，Customer类属性字段分别为：public   Int64   CustomerID ，public   decimal   Score ，   public   int   Rank ；CustomerCenter类主要用来处理数据集合，建立public   IEnumerable&lt;Customer&gt;   Customers()处理数据内容列表，   public   IEnumerable&lt;Customer&gt;   CustomersByRank()加入排序修饰。下面是详细代码：&lt;div align=&quot;left&quot; style=&quot;width: auto; text-indent: 12px; font-variant-numeric: normal; font-variant-east-asian: normal; font-variant-alternates: normal; font-size-adjust: none; font-kern …]]></description>
<pubDate>Tue, 06 Aug 2024 12:05:03 GMT</pubDate>
<author></author>
</item>
</channel>
</rss>
