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


C# IQueryable.ToList方法代码示例

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


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

示例1: GetUsersPerUser

        public IQueryable<User> GetUsersPerUser(User user, IQueryable<User> usersList)
        {
            var userRole = userServices.GetUserRoles(user.Id).First();
            List<User> resultList = new List<User>();
            switch (userRole.Name)
            {
                case "Administrator":
                    resultList = usersList.ToList();
                    break;
                case "Moderator":
                    foreach (var currentUser in usersList)
                    {
                        if (currentUser.Group != null && currentUser.Group.SchoolId == user.Moderator.First().Id)
                        {
                            resultList.Add(currentUser);
                        }
                        else if (currentUser.Group == null && currentUser.Consultant.First().Id == user.Moderator.First().Id)
                        {
                            resultList.Add(currentUser);
                        }
                    }
                    break;
                case "Adviser":
                    foreach (var currentUser in usersList)
                    {
                        if (currentUser.Group != null && currentUser.Group.SchoolId == user.Consultant.First().Id)
                        {
                            resultList.Add(currentUser);
                        }
                    }
                    break;
                case "Teacher":
                    foreach (var currentUser in usersList)
                    {
                        if (currentUser.Group != null && currentUser.Group.SchoolId == user.Group.SchoolId)
                        {
                            resultList.Add(currentUser);
                        }
                    }
                    break;
                case "Student":
                    break;
                default:
                    resultList = usersList.ToList();
                    break;
            }

            return resultList.AsQueryable();
        }
开发者ID:Spurch,项目名称:InteractiveLearningSystem,代码行数:49,代码来源:UsersFilter.cs

示例2: BatchDelete

 public void BatchDelete(IQueryable<ActivityData> activityData, string message, string userId)
 {
     foreach (ActivityData item in activityData.ToList())
     {
         DeleteActivityData(item.Id, message, userId);
     }
 }
开发者ID:cgddrd,项目名称:GoAber,代码行数:7,代码来源:ActivityDataService.cs

示例3: CheckUser

        public static bool CheckUser(MembershipAccount user, IQueryable<MembershipRole> roles, IQueryable<MembershipPermission> permissionsQuery, string[] currentPermissions)
        {
            List<MembershipPermission> allPermissions = permissionsQuery.ToList();
            List<string> permissions = new List<string>();

            if (user == null)
            {
                var role = roles.FirstOrDefault(x => x.RoleName == DefaultRoles.Anonymous);
                if (role != null)
                    permissions = role.Permissions;
            }
            else
            {
                permissions = user
                    .Roles
                    .SelectMany(x => x.Permissions)
                    .ToList();
                permissions.AddRange(user.Permissions);
            }

            var currentPermissionEntities = allPermissions.Where(x => currentPermissions.Any(y => y == x.Name)).ToList();
            if (permissions.Any(x => currentPermissionEntities.FirstOrDefault(y => y.Name == x) != null))
            {
                return true;
            }
            else
            {
                return false;
            }
        }
开发者ID:JoachimL,项目名称:MongoMembership,代码行数:30,代码来源:AuthorizeHelper.cs

示例4: GetProfileInfo

 public ArrayList GetProfileInfo(string EMP_ID)
 {
     MYPROFILE = MYPROFILE.Where(String.Format(@"EMP_ID=={0}", EMP_ID));
     ArrayList arr = new ArrayList();
     arr.Add(MYPROFILE.ToList());
     return arr;
 }
开发者ID:pareshf,项目名称:testthailand,代码行数:7,代码来源:UserProfileWebService.asmx.cs

示例5: GetRelatedImplantCostDetail

        public virtual List<CostDetail> GetRelatedImplantCostDetail(string codProductPartTask, IQueryable<Cost> costs)
        {
            List<CostDetail> lst = new List<CostDetail>();

            var x = CreatorImplantCostDetail();

            x.ComputedBy = this;
            x.ProductPart = this.ProductPart;

            //devo pescare il costo e associarlo al dettaglio
            if (x.CodCost == null)
            {
                var xxxx = costs.ToList();

                var cost = costs.Where(pp => pp.CodProductPartImplantTask == codProductPartTask).FirstOrDefault();
                //da non usare MAIIII                    x.TaskCost = cost;
                x.CodCost = cost.CodCost;
                x.CodCostDetail = cost.CodCost;

                x.CostDetailCostCodeRigen();
            }

            //GUID
            x.Guid = this.Guid;
            this.Computes.Add(x);
            lst.Add(x);

            return lst;
        }
开发者ID:algola,项目名称:backup,代码行数:29,代码来源:CostDetail.cs

示例6: GetUserInfo

 public ArrayList GetUserInfo(string EMP_ID)
 {
     USERDETAIL = USERDETAIL.Where(String.Format(@"EMP_ID=={0}", EMP_ID));
     ArrayList arr = new ArrayList();
     arr.Add(USERDETAIL.ToList());
     return arr;
 }
开发者ID:pareshf,项目名称:testthailand,代码行数:7,代码来源:UserProfileWebService.asmx.cs

示例7: AddOrderBy

 public void AddOrderBy()
 {
     Expression<Func<TestDataObject, string>> e = (o) => o.StringProperty;
     list = list.AddOrderBy(e);
     Assert.That(list.ToList().Count, Is.EqualTo(9));
     Assert.That(list.ToList()[0].ID, Is.EqualTo(8)); // Eighth
 }
开发者ID:daszat,项目名称:zetbox,代码行数:7,代码来源:LinqExtensionsTests.cs

示例8: PackageListViewModel

        public PackageListViewModel(
            IQueryable<Package> packages,
            DateTime? indexTimestampUtc,
            string searchTerm,
            int totalCount,
            int pageIndex,
            int pageSize,
            UrlHelper url,
            string curatedFeed)
        {
            // TODO: Implement actual sorting
            IEnumerable<ListPackageItemViewModel> items = packages.ToList().Select(pv => new ListPackageItemViewModel(pv));
            PageIndex = pageIndex;
            IndexTimestampUtc = indexTimestampUtc;
            PageSize = pageSize;
            TotalCount = totalCount;
            SearchTerm = searchTerm;
            int pageCount = (TotalCount + PageSize - 1) / PageSize;

            var pager = new PreviousNextPagerViewModel<ListPackageItemViewModel>(
                items,
                PageIndex,
                pageCount,
                page => curatedFeed == null ?
                    url.PackageList(page, searchTerm) :
                    url.CuratedPackageList(page, searchTerm, curatedFeed)
                );
            Items = pager.Items;
            FirstResultIndex = 1 + (PageIndex * PageSize);
            LastResultIndex = FirstResultIndex + Items.Count() - 1;
            Pager = pager;
        }
开发者ID:hugoparedes,项目名称:NuGetGallery,代码行数:32,代码来源:PackageListViewModel.cs

示例9: PackageListViewModel

        public PackageListViewModel(IQueryable<Package> packages,
            string searchTerm,
            string sortOrder,
            int totalCount,
            int pageIndex,
            int pageSize,
            UrlHelper url,
            bool includePrerelease)
        {
            // TODO: Implement actual sorting
            IEnumerable<ListPackageItemViewModel> items;
            using (MiniProfiler.Current.Step("Querying and mapping packages to list"))
            {
                items = packages.ToList()
                                .Select(pv => new ListPackageItemViewModel(pv, needAuthors: false));
            }
            PageIndex = pageIndex;
            PageSize = pageSize;
            TotalCount = totalCount;
            SortOrder = sortOrder;
            SearchTerm = searchTerm;
            int pageCount = (TotalCount + PageSize - 1) / PageSize;

            var pager = new PreviousNextPagerViewModel<ListPackageItemViewModel>(
                items,
                PageIndex,
                pageCount,
                page => url.PackageList(page, sortOrder, searchTerm, includePrerelease)
            );
            Items = pager.Items;
            FirstResultIndex = 1 + (PageIndex * PageSize);
            LastResultIndex = FirstResultIndex + Items.Count() - 1;
            Pager = pager;
            IncludePrerelease = includePrerelease ? "true" : null;
        }
开发者ID:Redsandro,项目名称:chocolatey.org,代码行数:35,代码来源:PackageListViewModel.cs

示例10: FilteredPagedResult

        protected ActionResult FilteredPagedResult(
            RavenQueryStatistics stats
            , IQueryable<Post> query
            , string slug
            , Func<Post, string> resolveSlug)
        {
            ViewBag.Slug = slug;

            var posts = query.ToList();

             // nothing returned by filter, this means that it does not exists!
             // if posts are empty, but TotalResults contains values
             // it means that we are on page that will not display anything
             if (stats.TotalResults == 0)
             {
                 var suggestions = query.Suggest();

                 if (suggestions.Suggestions.Length > 0)
                 {
                     return View("suggest", suggestions.Suggestions);
                 }

                 return HttpNotFound();
             }

            var resolvedSlug = resolveSlug(posts.FirstOrDefault());
            ViewBag.ResolvedSlug = resolvedSlug;
            return PagedResult(stats.TotalResults, posts);
        }
开发者ID:Gutek,项目名称:MovingScrewdriver,代码行数:29,代码来源:PostsPagingController.cs

示例11: CreateHeroesReport

        public void CreateHeroesReport(IQueryable<Hero> heroesData)
        {
            Encoding encoding = Encoding.GetEncoding("windows-1251");

            using (XmlTextWriter writer = new XmlTextWriter(workingDir + "/Heroes.xml", encoding))
            {
                Console.WriteLine("Writing of Heroes.xml initialized.");

                writer.Formatting = Formatting.Indented;
                writer.IndentChar = ' ';
                writer.Indentation = 2;

                writer.WriteStartDocument();
                writer.WriteStartElement("heroes");

                var heroes = heroesData.ToList();
                foreach (var hero in heroes)
                {
                    this.WriteHero(writer, hero);
                }

                writer.WriteEndDocument();
                Console.WriteLine("Heroes.xml created!");
            }
        }
开发者ID:Team-Neptunium,项目名称:Databases-Team-Neptunium,代码行数:25,代码来源:XmlGenerator.cs

示例12: Get

        public static List<Game> Get(IQueryable<Game> table, int start, int end)
        {
            if (start <= 0)
                start = 1;
            List<Game> l =table.ToList().Skip(start - 1).Take(end - start + 1).ToList();

            return l;
        }
开发者ID:lengocluyen,项目名称:pescode,代码行数:8,代码来源:Game.cs

示例13: InitSoldeBudgets

        // InitSoldeBudgets
        private IList<SoldeBudget> InitSoldeBudgets(IQueryable<Budget> _budgets)
        {
            // Initialisation des feeds
            IList<SoldeBudget> _soldeBudgets = new List<SoldeBudget>();

            // Constitution des feeds à partir des budgets
            _budgets.ToList().ForEach(b => _soldeBudgets.Add(new SoldeBudget(b)));
            return _soldeBudgets;
        }
开发者ID:paulkornikov,项目名称:Pragonas,代码行数:10,代码来源:SoldeBudgetFabrique.cs

示例14: DistinctPackages

		/// <summary>
		/// If we have jQuery 1.6 and 1.7 then return just jquery 1.6
		/// </summary>
		IEnumerable<IPackage> DistinctPackages(IQueryable<IPackage> localPackages)
		{
			List<IPackage> packages = localPackages.ToList();
			if (packages.Any()) {
				packages.Sort(PackageComparer.Version);
				return packages.Distinct(PackageEqualityComparer.Id).ToList();
			}
			return packages;
		}
开发者ID:kristjan84,项目名称:SharpDevelop,代码行数:12,代码来源:UpdatedPackages.cs

示例15: GetListUsers

        // GET: GetListUserList
        public PartialViewResult GetListUsers(string SortOrder, string CurrentFilter, string SearchString, int? Page = 1)
        {
            int pageSize = 10;

            ViewBag.CurrentSort = SortOrder;
            ViewBag.NameSortParm = String.IsNullOrEmpty(SortOrder) ? "Name_desc" : "";
            ViewBag.UsernameSortParm = SortOrder == "Username" ? "Username_desc" : "Username";
            ViewBag.EmailSortParm = SortOrder == "Email" ? "Email_desc" : "Email";

            if (SearchString != null)
            {
                Page = 1;
            }
            else
            {
                SearchString = CurrentFilter;
            }

            ViewBag.CurrentFilter = SearchString;

            UserList = UOW.UserRepository.Get();

            if (!String.IsNullOrEmpty(SearchString))
            {
                UserList = UserList.Where(s => s.Name.Contains(SearchString)
                                           || s.Username.Contains(SearchString)
                                           || s.EmailAdress.Contains(SearchString));
            }

            ViewBag.Count = UserList.Count();

            switch (SortOrder)
            {
                case "Name_desc":
                    UserList = UserList.OrderByDescending(s => s.Name);
                    break;
                case "Username":
                    UserList = UserList.OrderBy(s => s.Username);
                    break;
                case "Username_desc":
                    UserList = UserList.OrderByDescending(s => s.Username);
                    break;
                case "Email":
                    UserList = UserList.OrderBy(s => s.EmailAdress);
                    break;
                case "Email_desc":
                    UserList = UserList.OrderByDescending(s => s.EmailAdress);
                    break;
                default:
                    UserList = UserList.OrderBy(s => s.Name);
                    break;
            }

            int pageNumber = (Page ?? 1);

            return PartialView("GetListUsers",UserList.ToList().ToPagedList(pageNumber, pageSize));
        }
开发者ID:marquesdasilva,项目名称:UserManager_v02,代码行数:58,代码来源:WBUserListController.cs


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