Ilist泛型序列化后webservice问题

本文提供了两个使用 C# 编写的 WebMethod 示例,分别展示了如何获取部门信息列表和用户信息列表,并进行了相应的数据处理。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

ContractedBlock.gifExpandedBlockStart.gifCode
 1//ref
 2using System.Xml.Serialization;
 3using System.Collections.Generic;
 4
 5 
 6
 7        [WebMethod]
 8        [XmlInclude(typeof(DeptModel))]
 9        public IList GetDepModelList(string Deptname,int isdel)
10ExpandedBlockStart.gifContractedBlock.gif        {
11            ICommDal<DeptModel> iDal=new DeptDal();
12            IList<DeptModel> ilist = iDal.GetModelList(new DeptModel(0, Deptname, isdel, DateTime.Now));
13            IList list=new ArrayList();
14            for(int i=0;i<ilist.Count;i++)
15ExpandedSubBlockStart.gifContractedSubBlock.gif            {
16                list.Add(new DeptModel(ilist[i].Id, ilist[i].Deptname, ilist[i].Isdel, ilist[i].Createdate));
17            }

18            return list;
19           
20        }

21        [WebMethod]
22        [XmlInclude(typeof(UserModel))]
23        public IList GetUserModelList(string Username, int deptid)
24ExpandedBlockStart.gifContractedBlock.gif        {
25            ICommDal<UserModel> iDal = new UserDal();
26            IList<UserModel> ilist = iDal.GetModelList(new UserModel(0, Username, """", deptid, 0, DateTime.Now, 1""));
27            IList list = new ArrayList();
28            for (int i = 0; i < ilist.Count; i++)
29ExpandedSubBlockStart.gifContractedSubBlock.gif            {
30                UserModel model = new UserModel();
31                model.Createdate = ilist[i].Createdate;
32                model.Dept = ilist[i].Dept;
33                model.Deptname = ilist[i].Deptname;
34                model.Group = ilist[i].Group;
35                model.Groupname = ilist[i].Groupname;
36                model.Id = ilist[i].Id;
37                model.Isdel = ilist[i].Isdel;
38                model.Password = ilist[i].Password;
39                model.True_password = ilist[i].True_password;
40                model.Truename = ilist[i].Truename;
41                model.Username = ilist[i].Username;
42                list.Add(model);
43            }

44           
45            return list;
46        }

47

这样才可以调用,调试成功,不知道还有没有别的方法,总是感觉怪怪的.

转载于:https://www.cnblogs.com/vincentfeng/archive/2009/08/17/1548295.html

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值