感觉WCF给分布式开发带来的方便不是一般的,效率好像也还不错(编译好第1+n次的访问速度总是比第n次快【本机上】),
然后用LinQ写了个简单的DataAccessLayer,先是定义接口,我们叫它做契约!它加了WCF的特性,继承自它的服务会自动继承其特性,数据库用Northwind
1
using System;
2
using System.Collections.Generic;
3
using System.Linq;
4
using System.Text;
5
using ExtjsNorthwind.Model;
6
using System.ServiceModel;
7
using System.ServiceModel.Web;
8
namespace ExtjsNorthwind.ServiceContract
9
}
接下来实现这个契约2
3
4
5
6
7
8
9
此外测试了一个简单的一对多的序列化
写了一个Student类代码很简单,就不贴了,其中有一个List<Product>类型得ProductList属性,返回这个学生买的产品资料!加上[DataMember]特性!OK:代码下载