当前位置: 首页>>代码示例>>C#>>正文


C# TList.Where方法代码示例

本文整理汇总了C#中TList.Where方法的典型用法代码示例。如果您正苦于以下问题:C# TList.Where方法的具体用法?C# TList.Where怎么用?C# TList.Where使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在TList的用法示例。


在下文中一共展示了TList.Where方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: BuildListSection

    /// <summary>
    /// Build object to string result
    /// </summary>
    /// <param name="lstRosters"></param>
    /// <param name="date"></param>
    /// <returns></returns>
    private static object BuildListSection(TList<Roster> lstRosters, DateTime? date)
    {
        object lst = null;
        try
        {
            DataRepository.RosterProvider.DeepLoad(lstRosters);

            // Lay danh sach doctor theo appointment
            var lstDoctor = new TList<Users>();

            // Lay danh sach service theo appointment
            var lstService = new TList<Services>();

            foreach (var roster in lstRosters)
            {
                Roster roster1 = roster;
                if (!lstDoctor.Exists(doctor => doctor.Username == roster1.Username))
                {
                    lstDoctor.Add(roster.UsernameSource);
                }

                lstDoctor.Sort((p1, p2) => p1.DisplayName.CompareTo(p2.DisplayName));

                DataRepository.UsersProvider.DeepLoad(roster1.UsernameSource);

                if (!lstService.Exists(service => service.Id == roster1.UsernameSource.ServicesId))
                {
                    lstService.Add(DataRepository.ServicesProvider.GetById(Convert.ToInt32(roster1.UsernameSource.ServicesId)));
                }
            }

            // Sort theo priority
            lstService.Sort("PriorityIndex ASC");

            var dtStart = Convert.ToDateTime(date);
            var dtEnd = new DateTime(dtStart.Year, dtStart.Month, dtStart.Day, 23, 59, 59);
            dtStart = new DateTime(dtStart.Year, dtStart.Month, dtStart.Day);

            lst = lstService.Select(service => new
                {
                    service.Id,
                    Title = string.IsNullOrEmpty(service.ShortTitle) ? service.Title : service.ShortTitle,
                    Date = String.Format("{0:MM-dd-yyyy HH:mm:ss}", date),
                    Doctors = lstDoctor.Where(doctor => doctor.ServicesId == service.Id)
                        .Select(doctor => new
                        {
                            key = doctor.Username,
                            label = doctor.DisplayName,
                            Rosters = lstRosters.Where(roster => roster.Username == doctor.Username)
                                .Select(roster => new
                                    {
                                        startTime = (roster.StartTime < dtStart ? dtStart : roster.StartTime).ToString("MM-dd-yyyy HH:mm:ss"),
                                        endTime = (roster.EndTime > dtEnd ? dtEnd : roster.EndTime).ToString("MM-dd-yyyy HH:mm:ss"),
                                        color = roster.RosterTypeIdSource.ColorCode
                                    }).ToList()
                        }).ToList()
                }).ToList();
        }
        catch (Exception ex)
        {
            LoggerController.WriteLog(System.Runtime.InteropServices.Marshal.GetExceptionCode(), ex, Network.GetIpClient());
        }
        return lst;
    }
开发者ID:williams55,项目名称:clinic-doctor,代码行数:70,代码来源:Default.aspx.cs


注:本文中的TList.Where方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。