WCF学习笔记——配置服务引用

来源:互联网 发布:php源码 网络验证 编辑:程序博客网 时间:2024/06/06 03:01

WCF传过来的东西要序列化。

比如,在WCF服务中,象这么个方法

public IEnumerable<UserItem> GetUserList()

默认情况下,在客户端会调用,是这样:

//ServiceReference1,服务引用            using (ServiceReference1.UserListClient client = new ServiceReference1.UserListClient())        {            ServiceReference1.UserItem[] list = client.GetUserList();        }

但是我们在WPF中,多用 ObservableCollection,那么如何转换?

当然可以在代码中加以转换,但更省事的是配置服务引用:

在VS中,右击这个服务引用,选配置服务引用,然后

集合类型:System.Collections.ObjectModel.ObservableCollection

字典集合类型:System.Collections.Generic.Dictionary


如此,WCF服务中的IEnumerable,在客户端,即可自动换成 ObservableCollection 矣

0 0
原创粉丝点击