将FindItemsResults <appointment>转换为List <约会> </约会> </约会>

时间:2014-02-17 17:01:19

标签: c# exchange-server exchangewebservices

我有一个庞大的资源邮箱列表,我从中获取所有日历项目。目前,为了让他们从FindItemResults<Appointment>List<Appointment>,我正在执行以下操作:

    FindItemsResults<Appointment> tApts = service.FindAppointments(CalendarFolderID, cv);
    Collection<Appointment> tApts2 = tApts.Items;
    List<Appointment> apts = tApts2.Cast<Appointment>().ToList();

这是最好的方法吗?从FindITemResults - &gt;开始似乎是多余的。 Collection - &gt; List

有没有办法绕过Collection<Appointment>次转化?

1 个答案:

答案 0 :(得分:1)

你应该可以这样做:

FindItemsResults<Appointment> tApts = service.FindAppointments(CalendarFolderID, cv);
List<Appointment> apts = tApts.Items.ToList<Appointment>();

Items属性为Collection<T>,只要您在cs文件中定义了.ToList(),就可以使用扩展方法using System.Linq;进行{{1}}。

希望这有帮助。

相关问题