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


C# IEnumerable.AsQueryable方法代码示例

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


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

示例1: PredictionViewModel

        public PredictionViewModel(Season currentSeason, Player currentLoggedInPlayer, IEnumerable<Comment> Comments)
        {
            LoggedInPlayer = currentLoggedInPlayer;

            Week week = currentSeason.GetCurrentWeekSeason();
            CurrentWeekText =  string.Format("This Week runs from {0} too {1}, This weeks cutoff for predictions is at {2} on the {3}",
                                week.WeekStarts.ordinalDateShortDay(),
                                week.WeekEnds.ordinalDateShortDay(),
                                week.WeekCutOff.ToString("hh:mm tt"),
                                week.WeekCutOff.ordinalDateShortDay());

            ThisWeeksMatches = week.AllMatches().OrderBy(m =>m.MatchDate.Value);

            MatchOfTheWeek = week.MatchOfTheWeek;

            var PPs = new Dictionary<Player, IEnumerable<PlayerPrediction>>();
            var PlayersWithCompletedPredictions = currentSeason.League.Players.Where(p => p.HasCompletedPredictions(week));
            foreach (var p in PlayersWithCompletedPredictions.OrderByDescending(x=>x.CurrentTotalPoints(currentSeason)))
            {
                PPs.Add(p, p.GetPredictionsForThisWeek().OrderBy(m => m.Match.MatchDate.Value));
            }

            PlayerPredictions = PPs;

            //comments
            CommentModel = new CommentingViewModel(7, week.Id, Comments.AsQueryable(), LoggedInPlayer);
        }
开发者ID:elmo61,项目名称:BritBoxing,代码行数:27,代码来源:PredictionSummary.cs

示例2: FindBiggestCommonType

        /// <summary>
        /// Finds the biggest common type of items in the list.
        /// </summary>
        /// <param name="items">The list.</param>
        /// <returns>
        /// The biggest common type.
        /// </returns>
        public static Type FindBiggestCommonType(IEnumerable items)
        {
            if (items == null)
            {
                return null;
            }

            Type type = null;
            foreach (var item in items)
            {
                if (item == null)
                {
                    continue;
                }

                Type itemType = item.GetType();
                if (type == null)
                {
                    type = itemType;
                    continue;
                }

                while (type != null && type.BaseType != null && !type.IsAssignableFrom(itemType))
                {
                    type = type.BaseType;
                }
            }

            if (type == null && items is IList)
            {
                type = items.AsQueryable().ElementType;
            }

            return type;
        }
开发者ID:yovannyr,项目名称:PropertyTools,代码行数:42,代码来源:TypeHelper.cs

示例3: AnnualExpenseSummary

        public AnnualExpenseSummary(Client client, IEnumerable<Employee> employees)
        {
            ClientCompany = client;
            Employees = employees.AsQueryable();

            CalculatStatistics();
        }
开发者ID:MatthewVines,项目名称:Pay,代码行数:7,代码来源:AnnualExpenseSummary.cs

示例4: TestJoinOnly

        public void TestJoinOnly(IEnumerable<Foo> foos, IEnumerable<Foo> bars)
        {
            var actual = Factory.MemoryGroupJoin(foos.AsQueryable(), bars.AsQueryable(), f => f.Id, b => b.Id, (f, b) => new { Id = f.Id, BarCount = b.Count() });
            var expected = foos.GroupJoin(bars, f => f.Id, i => i.Id, (f, b) => new { Id = f.Id, BarCount = b.Count() });

            Assert.That(actual.ToArray(), Is.EquivalentTo(expected));
        }
开发者ID:2gis,项目名称:nuclear-join,代码行数:7,代码来源:GroupJoinTest.cs

示例5: GetResult

		public IEnumerable<ShipData> GetResult( IEnumerable<ShipData> list ) {

			if ( predicate == null )
				throw new InvalidOperationException( "式がコンパイルされていません。" );

			return list.AsQueryable().Where( predicate ).AsEnumerable();
		}
开发者ID:CoRelaxuma,项目名称:ElectronicObserver,代码行数:7,代码来源:ExpressionManager.cs

示例6: SetUp

                public override void SetUp()
                {
                    base.SetUp();
                    _patients = Fixture.CreateMany<Domain.Patient>();

                    _patientRepositoryMock.Setup(r => r.GetPatients()).Returns(_patients.AsQueryable());
                }
开发者ID:JoachimL,项目名称:ProstateBioBank,代码行数:7,代码来源:PatientStoreTests.cs

示例7: SetupUnitOfWork

 private Mock<IUnitOfWork> SetupUnitOfWork(IEnumerable<Form> data)
 {
     var unitOfWork = new Mock<IUnitOfWork>();
     string[] includeNames = { "Topics", "Topics.Questions", "Topics.Questions.Answers" };
     unitOfWork.Setup(u => u.Query<Form>(includeNames)).Returns(data.AsQueryable());
     return unitOfWork;
 }
开发者ID:hmeydac,项目名称:Bishop,代码行数:7,代码来源:FormServiceTests.cs

示例8: EstablishContext

        protected override void EstablishContext()
        {
            //Prepare supplied data collections
            suppliedListMetadata = GetSuppliedListMetadata();
            suppliedStudentRow = GetSuppliedStudentRow();
            suppliedPriorYearStudentRow = GetSuppliedPriorYearStudentList();
            suppliedMetricVariants = GetSuppliedMetricVariants();

            //Set up the mocks
            listMetadataProvider = mocks.StrictMock<IListMetadataProvider>();
            studentListUtilitiesProvider = mocks.StrictMock<IStudentListUtilitiesProvider>();
            trendRenderingDispositionProvider = mocks.StrictMock<ITrendRenderingDispositionProvider>();
            metricStateProvider = mocks.StrictMock<IMetricStateProvider>();
            metricVariantRepository = mocks.StrictMock<IRepository<MetricVariant>>();

            windsorContainer = new WindsorContainer();
            windsorContainer.Kernel.Resolver.AddSubResolver(new ArrayResolver(windsorContainer.Kernel));
            RegisterProviders(windsorContainer);
            IoC.Initialize(windsorContainer);

            additionalPriorYearMetricProvider = IoC.Resolve<IAdditionalPriorYearMetricProvider>();

            Expect.Call(metricVariantRepository.GetAll())
                .Return(suppliedMetricVariants.AsQueryable()).Repeat.AtLeastOnce();
        }
开发者ID:sybrix,项目名称:EdFi-App,代码行数:25,代码来源:PriorYearClassroomMetricsProviderFixture.cs

示例9: SetUp

        public void SetUp()
        {
            _documents = new List<Document> {new Document()};
            var repository = MockRepository.GenerateMock<IRepository>();
            _homeController = new HomeController(repository);

            repository.Stub(x => x.All<Document>()).Return(_documents.AsQueryable());
        }
开发者ID:cerikpete,项目名称:FrictionlessTesting,代码行数:8,代码来源:HomeControllerOldStyleSpecs.cs

示例10: Create

        public static IPackageRepositoryFactory Create(IEnumerable<IPackage> packages)
        {
            var packageRepositoryFactory = Substitute.For<IPackageRepositoryFactory>();

            packageRepositoryFactory
                .CreateRepository("repository")
                .GetPackages()
                .Returns(packages.AsQueryable());
            return packageRepositoryFactory;
        }
开发者ID:caleb-vear,项目名称:NuSelfUpdate,代码行数:10,代码来源:PackageRepositoryFactories.cs

示例11: Delete

 public void Delete(IEnumerable<long> itemKeys)
 {
     _items.Query()
         .Join(itemKeys.AsQueryable(),
               item => item.ItemPKey, key => key,
               (item, key) => item)
         .ToList()
         .ForEach(itm => _items.Delete(itm));
     _save.Save();
 }
开发者ID:JakeKalstad,项目名称:Inventory-Management,代码行数:10,代码来源:DeleteItem.cs

示例12: TownRepositoryWithOptimizeRegionTestHelper

 public TownRepositoryWithOptimizeRegionTestHelper(
     IEnumerable<Town> towns, IEnumerable<OptimizeRegion> regions)
 {
     this.towns = towns;
     this.regions = regions;
     townRepository.Setup(x => x.GetAll()).Returns(towns.AsQueryable());
     townRepository.Setup(x => x.GetAllList()).Returns(townRepository.Object.GetAll().ToList());
     townRepository.Setup(x => x.Count()).Returns(townRepository.Object.GetAll().Count());
     controller = new RegionController(townRepository.Object, null, null, regionRepository.Object);
 }
开发者ID:ouyh18,项目名称:LteTools,代码行数:10,代码来源:TownRepositoryWithOptimizeRegionTest.cs

示例13: CheckMetadataStringOperator

        private IEnumerable<Node> CheckMetadataStringOperator(MappingToolDatabaseDataContext dbContext, IEnumerable<Node> nodes, GraphQueryMetadata metadataTest)
        {
            List<Node> filteredNodes = null;

            if (metadataTest.Operator.Equals("Contains", StringComparison.InvariantCultureIgnoreCase))
            {
                IQueryable<Node> queryableNodes = nodes.AsQueryable();
                var filteredMetadata = from dbMetadata in dbContext.udf_SearchMetadataContains(metadataTest.Name, metadataTest.Value) select dbMetadata;
                int counter = filteredMetadata.Count();
                filteredNodes = nodes.Join(filteredMetadata, x => x.NodeUid, y => y.NodeUid, (a, b) => a).ToList();
            }
            else if (metadataTest.Operator.Equals("FreeText", StringComparison.InvariantCultureIgnoreCase))
            {
                IQueryable<Node> queryableNodes = nodes.AsQueryable();
                var filteredMetadata = from dbMetadata in dbContext.udf_SearchMetadataFreeText(metadataTest.Name, metadataTest.Value) select dbMetadata;
                int counter = filteredMetadata.Count();
                filteredNodes = nodes.Join(filteredMetadata, x => x.NodeUid, y => y.NodeUid, (a, b) => a).ToList();
            }
            else
            {
                filteredNodes = new List<Node>();

                foreach (Node node in nodes)
                {
                    if (metadataTest.Operator.Equals("Equals", StringComparison.InvariantCultureIgnoreCase))
                    {
                        if (node.Metadatas.Where(metadata => metadata.MetadataName == metadataTest.Name && metadata.MetadataValue.Contains(metadataTest.Value)).Count() > 0)
                        {
                            filteredNodes.Add(node);
                        }
                    }
                    else if (metadataTest.Operator.Equals("NotEquals", StringComparison.InvariantCultureIgnoreCase))
                    {
                        if (node.Metadatas.Where(metadata => metadata.MetadataName == metadataTest.Name && metadata.MetadataValue != metadataTest.Value).Count() > 0)
                        {
                            filteredNodes.Add(node);
                        }
                    }
                }
            }

            return filteredNodes;
        }
开发者ID:chris-tomich,项目名称:Glyma,代码行数:43,代码来源:GraphQueryFilter_Class.cs

示例14: OnNewsItemsAvailable

        private void OnNewsItemsAvailable(IEnumerable<NewsItem> newsItems, object userState)
        {
            IEnumerable<NewsItem> orderedItems = newsItems.AsQueryable().OrderByDescending(i => i.PublishDate);

            ViewActionResult result = View("List");
            result.ViewData["Items"] = orderedItems.ToArray();

            Task<ActionResult> task = (Task<ActionResult>)userState;
            task.Complete(result);
        }
开发者ID:jaddington,项目名称:silverlightfx,代码行数:10,代码来源:NewsController.cs

示例15: FindResources

        public void FindResources(string searchTerm)
        {
            string searchTermLower = searchTerm.ToLowerInvariant();

            data = DataManager.Resources.Where(item => (item.Title.ToLowerInvariant().Contains(searchTermLower) || item.Tags.ToLowerInvariant().Contains(searchTermLower)));

            results.ItemsSource = data;
            this.DataContext = data;

            OnSearchCompleted(new SearchEventArgs(data.AsQueryable()));
        }
开发者ID:lokswin,项目名称:ivu-cher,代码行数:11,代码来源:SearchInterface.xaml.cs


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