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


C# IList.AsQueryable方法代码示例

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


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

示例1: AllowTransitions

 /// <inheritdoc />
 public IEnumerable<ITransition> AllowTransitions(IList<ITransition> transitions)
 {
     return from t in transitions.AsQueryable()
                join a in this.allowedTransitions.AsQueryable()
                 on t.From equals a.From
                select t;
 }
开发者ID:rajeshgupthar,项目名称:objectflow,代码行数:8,代码来源:DefaultTransitionGateway.cs

示例2: SetupController

        public void SetupController()
        {
            resultsRows = Builder<AwsEc2Status>.CreateListOfSize(totalRows).Build();
            repository = Substitute.For<IRepository<AwsEc2Status>>();
            repository.All().Returns(resultsRows.AsQueryable());

            RepositorySession.DefaultContainerType = typeof(FakeObjectContext);

            controller = new QuartzController(repository);
        }
开发者ID:Adron,项目名称:AWS-Toolkit-Samples,代码行数:10,代码来源:QuartzController.cs

示例3: SetupUnitOfWork

        private IForumSystemData SetupUnitOfWork(IGenericRepository<Article> articlesRepository, IList<Article> articles)
        {
            Mock.Arrange(() => articlesRepository.All())
                .Returns(() => articles.AsQueryable());

            var forumSystemData = Mock.Create<IForumSystemData>();
            Mock.Arrange(() => forumSystemData.Articles)
                .Returns(() => articlesRepository);

            return forumSystemData;
        }
开发者ID:jesconsa,项目名称:Telerik-Academy,代码行数:11,代码来源:ArticlesControllerTest.cs

示例4: TransitionsInCommonWithList

        /// <summary></summary>
        protected IEnumerable<ITransition> TransitionsInCommonWithList(IList<ITransition> transitions)
        {
            var list = TransitionList();
            list = list ?? EMPTY_TRANSITIONS;

            var result = from a in transitions.AsQueryable()
                         join b in list.AsQueryable() on a.From equals b.From
                         where object.Equals(a.To, b.To) && object.Equals(_workflowId, a.WorkflowId)
                         select a;

            return result;
        }
开发者ID:rajeshgupthar,项目名称:objectflow,代码行数:13,代码来源:AbstractTransitionGateway.cs

示例5: SetupController

        public void SetupController()
        {
            resultsRows = Builder<NiceLittleForm>.CreateListOfSize(TotalRows).Build();

            repository = Substitute.For<IRepository<NiceLittleForm>>();
            session = Substitute.For<IRepositorySession>();
            repository.All().Returns(resultsRows.AsQueryable());

            RepositorySession.DefaultContainerType = typeof(FakeObjectContext);

            controller = new NiceLittleFormController(repository, session);
        }
开发者ID:Adron,项目名称:AWS-Toolkit-Samples,代码行数:12,代码来源:NiceLittleFormController.cs

示例6: Given

 public override void Given()
 {
     users = new List<User>() {
     new User("user1", "user1", "user", "one", "[email protected]").SetIdTo(1) as User,
     new User("user2", "user2", "user", "two", "[email protected]").SetIdTo(2) as User,
     new User("user3", "user3", "user", "three", "[email protected]").SetIdTo(3) as User
       };
       repository.Setup(r => r.All<User>()).Returns(users.AsQueryable());
       emailService.Setup(s => s.SendSystemEmail(It.IsAny<string>(), It.IsAny<string>(), It.IsAny<string>())).Callback(() => {
     emailAttempts++;
       });
       ControllerHelper.CreateMockControllerContext(controller);
       Mock.Get(controller.ControllerContext.HttpContext.Request).Setup(r => r.Url).Returns(new Uri("http://host/users/unapproved"));
 }
开发者ID:pwideman,项目名称:ClubPool,代码行数:14,代码来源:UnapprovedUsers.cs

示例7: SetupFixtures

 public void SetupFixtures()
 {
     _fixtures = new List<Dummy>
     {
         new Dummy { Id = "1", FirstName = "Thomas", LastName = "Paine" },
         new Dummy { Id = "2", FirstName = "Samuel", LastName = "Adams" },
         new Dummy { Id = "3", FirstName = "George", LastName = "Washington"},
         new Dummy { Id = "4", FirstName = "Thomas", LastName = "Jefferson" },
         new Dummy { Id = "5", FirstName = "Martha", LastName = "Washington"},
         new Dummy { Id = "6", FirstName = "Abraham", LastName = "Lincoln" },
         new Dummy { Id = "7", FirstName = "Andrew", LastName = "Jackson" },
         new Dummy { Id = "8", FirstName = "Andrew", LastName = "Johnson" },
         new Dummy { Id = "9", FirstName = "William", LastName = "Harrison" }
     };
     _fixturesQuery = _fixtures.AsQueryable();
 }
开发者ID:Eclarian,项目名称:JSONAPI.NET,代码行数:16,代码来源:DefaultPaginationTransformerTests.cs

示例8: EstablishContext

        public override void EstablishContext()
        {
            repository = new Mock<IRepository>();
              controller = new ScoresheetController(repository.Object);

              teams = new List<Team>();
              users = new List<User>();
              var matchResults = new List<MatchResult>();
              var matches = new List<Web.Models.Match>();
              meets = new List<Meet>();
              var divisions = new List<Division>();
              season = DomainModelHelper.CreateTestSeason(users, divisions, teams, meets, matches, matchResults);
              repository.InitAll(users.AsQueryable(), null, new List<Season> { season }.AsQueryable());
              foreach (var user in users) {
            user.UpdateSkillLevel(season.GameType, repository.Object);
              }
              adminUser = users[0];
        }
开发者ID:pwideman,项目名称:ClubPool,代码行数:18,代码来源:Scoresheet.cs

示例9: Init

        public void Init()
        {
            _organizations = new List<Organization> {
                new Organization{ Id = 1, Name = "Pos #1", StatusId = (byte)Status.Approved, ParentId = 0, CreatedAt = DateTime.Now },
                new Organization{ Id = 2, Name = "Pos #2", StatusId = (byte)Status.Approved, ParentId = 0, CreatedAt = DateTime.Now },
            };

            Organization pos1 = _organizations.OrderBy(x => x.Id).First();
            Organization pos2 = _organizations.OrderBy(x => x.Id).Skip(1).First();
            _categories = new List<Category> {
                new Category { Id = 2, Name = "Light alcohol", OrganizationId = pos1.Id, ParentId = 0, StatusId = (byte)Status.Approved, CategoryTypeId = 1 },
                new Category { Id = 2, Name = "Food", OrganizationId = pos1.Id, ParentId = 0, StatusId = (byte)Status.Approved, CategoryTypeId = 1 },
                new Category { Id = 3, Name = "Men shoes", OrganizationId = pos2.Id, ParentId = 0, StatusId = (byte)Status.Approved, CategoryTypeId = 1 },
                new Category { Id = 4, Name = "Women shoes", OrganizationId = pos2.Id, ParentId = 0, StatusId = (byte)Status.Approved, CategoryTypeId = 1 },
                new Category { Id = 5, Name = "Children shoes", OrganizationId = pos2.Id, ParentId = 0, StatusId = (byte)Status.Approved, CategoryTypeId = 1 }
            };

            Category lightAlcohol = _categories.First(x => x.Name.Contains("Light alcohol"));
            Category food = _categories.First(x => x.Name.Equals("Food"));
            _products = new List<Product> {
                    new Product { Id = 1, CategoryId = lightAlcohol.Id, InternalCode = "internal_001", Name = "Beer", PosId = pos1.Id, Price = 10m, StatusId = (byte)Status.Approved, Uid = "uid_0001", UserId = "TestUser", CreatedAt = DateTime.Now },
                    new Product { Id = 2, CategoryId = food.Id, InternalCode = "internal_002", Name = "Cheese", PosId = pos1.Id, Price = 15m, StatusId = (byte)Status.Approved, Uid = "uid_0002", UserId = "TestUser", CreatedAt = DateTime.Now },
                    new Product { Id = 3, CategoryId = lightAlcohol.Id, InternalCode = "internal_003", Name = "Beer light", PosId = pos1.Id, Price = 5m, StatusId = (byte)Status.Approved, Uid = "uid_0003", UserId = "TestUser", CreatedAt = DateTime.Now }
            };

            _organizationRepository = new Mock<IOrganizationRepository>();
            _organizationRepository.Setup(x => x.Organizations)
                .Returns(_organizations.AsQueryable());

            _categoryMock = new Mock<ICategoryRepository>();
            _categoryMock.Setup(x => x.Categories)
                .Returns(_categories.AsQueryable());

            _productRepository = new Mock<IProductRepository>();
            _productRepository.Setup(x => x.Products)
                .Returns(_products.AsQueryable());

            _categoryController = new CategoryController(
                _categoryMock.Object,
                _organizationRepository.Object,
                _productRepository.Object);
        }
开发者ID:vasialek,项目名称:onbalance,代码行数:42,代码来源:CategoriesTest.cs

示例10: EstablishContext

        public override void EstablishContext()
        {
            base.EstablishContext();
              users = new List<User>();
              divisions = new List<Division>();
              teams = new List<Team>();
              matches = new List<ClubPool.Web.Models.Match>();
              meets = new List<Meet>();
              matchResults = new List<MatchResult>();
              season = DomainModelHelper.CreateTestSeason(users, divisions, teams, meets, matches, matchResults);
              adminUser = users[0];
              officerUser = users[1];
              repository.Init<Division>(divisions.AsQueryable());
              repository.Init<User>(users.AsQueryable(), true);
              repository.Init<Team>(teams.AsQueryable(), true);
              repository.Init<MatchResult>(matchResults.AsQueryable());

              foreach (var user in users) {
            user.UpdateSkillLevel(season.GameType, repository.Object);
              }
              team = teams[0];
        }
开发者ID:pwideman,项目名称:ClubPool,代码行数:22,代码来源:Details.cs

示例11: MockUnitOfWorkForActionAll

        private IBugLoggerData MockUnitOfWorkForActionAll(IList<Bug> bugs)
        {
            var bugFakeRepository = Mock.Create<IBugRepository>();
            
            Mock.Arrange(() => bugFakeRepository.All())
                .Returns(() => bugs.AsQueryable());

            Mock.Arrange(() => bugFakeRepository.Add(Arg.IsAny<Bug>()))
                .DoInstead<Bug>((b) => bugs.Add(b));

            var bugLoggerData = Mock.Create<IBugLoggerData>();
            Mock.Arrange(() => bugLoggerData.Bugs)
                .Returns(() => bugFakeRepository);

            return bugLoggerData;
        }
开发者ID:jesconsa,项目名称:Telerik-Academy,代码行数:16,代码来源:Mocking.cs

示例12: GetPublishedNewsItemSummaryByIds

 public IList<ListenTo.Shared.DTO.NewsItemSummary> GetPublishedNewsItemSummaryByIds(IList<Guid> ids)
 {
     return GetNewsItemSummary().IsPublished().WithID(ids.AsQueryable<Guid>()).ToList();
 }
开发者ID:listentorick,项目名称:ListenTo,代码行数:4,代码来源:LinqToSQLRepository.cs

示例13: Save

        /// <summary>
        /// Convert và lưu dữ liệu import vào database.
        /// </summary>
        /// <param name="userID"></param>
        /// <param name="listImportData"></param>
        /// <returns></returns>
        public bool Save(Guid userID, IList listImportData, string userLogin)
        {
            bool result = false;

            if (!isDataSaved)
            {
                if (listImportData != null && listImportData.Count > 0)
                {
                    using (var context = new VnrHrmDataContext())
                    {
                        IUnitOfWork unitOfWork = new UnitOfWork(context);
                        var objectType = listImportData[0].GetPropertyValue(Constant.ObjectType);

                        IList listObj = new ArrayList();
                        var status = DataErrorCode.Success;

                        if (objectType != null)
                        {
                            if (this.ImportMode == ImportDataMode.Update || this.ImportMode == ImportDataMode.Skip)
                            {
                                var listObjectID = listImportData.AsQueryable().Select(Constant.ID).GetList().OfType<Guid>().Distinct().ToArray();
                                listEntityResult = unitOfWork.CreateQueryable(Guid.Empty, (Type)objectType, "@0.Contains(outerIt." + Constant.ID + ")", listObjectID).GetList();

                                foreach (var importData in listImportData)
                                {
                                    var objectID = importData.GetPropertyValue(Constant.ID).TryGetValue<Guid>();
                                    var objectDuplicate = listEntityResult.AsQueryable().Where(Constant.ID + " = @0", objectID).FirstOrDefault();

                                    if (objectDuplicate != null)
                                    {
                                        //Copy dữ liệu import vào dữ liệu trong database
                                        importData.CopyData(objectDuplicate, Constant.ID);
                                    }
                                    else if (this.ImportMode == ImportDataMode.Skip)
                                    {
                                        objectDuplicate = ((Type)objectType).CreateInstance();
                                        importData.CopyData(objectDuplicate, Constant.ID);
                                        unitOfWork.AddObject((Type)objectType, objectDuplicate);
                                    }

                                    if (objectDuplicate != null)
                                    {
                                        listObj.Add(objectDuplicate);
                                    }

                                    var currentIndex = listImportData.IndexOf(importData);

                                    if ((currentIndex + 1) == listImportData.Count || (currentIndex > 0
                                        && listImportData.IndexOf(importData) % 9999 == 0))
                                    {
                                        status = unitOfWork.SaveChanges(userID, true);
                                    }

                                    if (ProgressChanged != null)
                                    {
                                        double percent = ((double)listImportData.IndexOf(importData) / (double)listImportData.Count) * 100;
                                        ProgressChanged(new ProgressEventArgs
                                        {
                                            ID = UserID,
                                            Name = "SaveData",
                                            Value = "SaveData".TranslateString(),
                                            Percent = (int)percent
                                        });
                                    }
                                }

                                result = true;
                            }
                            else
                            {
                                listEntityResult = ((Type)objectType).CreateList();

                                foreach (var importData in listImportData)
                                {
                                    var objectDuplicate = ((Type)objectType).CreateInstance();
                                    importData.CopyData(objectDuplicate, Constant.ID);
                                    unitOfWork.AddObject((Type)objectType, objectDuplicate);

                                    var currentIndex = listImportData.IndexOf(importData);

                                    if ((currentIndex + 1) == listImportData.Count || (currentIndex > 0
                                        && listImportData.IndexOf(importData) % 9999 == 0))
                                    {
                                        status = unitOfWork.SaveChanges(userID, true);
                                    }

                                    if (ProgressChanged != null)
                                    {
                                        double percent = ((double)listImportData.IndexOf(importData) / (double)listImportData.Count) * 100;
                                        ProgressChanged(new ProgressEventArgs
                                        {
                                            ID = UserID,
                                            Name = "SaveData",
                                            Value = "SaveData".TranslateString(),
//.........这里部分代码省略.........
开发者ID:dtafe,项目名称:vnr,代码行数:101,代码来源:ImportService.cs

示例14: Init


//.........这里部分代码省略.........
                                               StatusID = 1,
                                               StartDate=DateTime.Today,
                                               EndDate=DateTime.Today,
                                               BidDocumentNo="xyz"
                                           }
                                   };

            var _transportRequisitons = new List<TransportRequisition>
                                            {
                                                new TransportRequisition
                                                    {
                                                        TransportRequisitionID = 1,
                                                        Status = 1,
                                                        TransportRequisitionNo = "001"
                                                    }
                                            };

            var _hubAllocation = new List<HubAllocation>
                                     {
                                         new HubAllocation
                                             {
                                                 RequisitionID = 1,
                                                 HubID = 1
                                             }
                                     };

            var mockUnitOfWork = new Mock<IUnitOfWork>();
            var mockReliefRequisitionRepository = new Mock<IGenericRepository<ReliefRequisition>>();
            mockReliefRequisitionRepository.Setup(
                t => t.Get(It.IsAny<Expression<Func<ReliefRequisition, bool>>>(), It.IsAny<Func<IQueryable<ReliefRequisition>, IOrderedQueryable<ReliefRequisition>>>(), It.IsAny<string>())).Returns(
                    (Expression<Func<ReliefRequisition, bool>> perdicate, Func<IQueryable<ReliefRequisition>, IOrderedQueryable<ReliefRequisition>> obrderBy, string prop) =>
                    {
                        var
                            result = _reliefRequisitions.AsQueryable();
                        return result;
                    }
                );
            mockReliefRequisitionRepository.Setup(t => t.FindById(It.IsAny<int>())).Returns((int id) => _reliefRequisitions
                                                                                                          .ToList().
                                                                                                          Find
                                                                                                          (t =>
                                                                                                           t.
                                                                                                               RequisitionID ==
                                                                                                           id));

            var mockReliefRequisionDetailRepository = new Mock<IGenericRepository<ReliefRequisitionDetail>>();
            mockReliefRequisionDetailRepository.Setup(
                 t => t.Get(It.IsAny<Expression<Func<ReliefRequisitionDetail, bool>>>(), It.IsAny<Func<IQueryable<ReliefRequisitionDetail>, IOrderedQueryable<ReliefRequisitionDetail>>>(), It.IsAny<string>())).Returns(
                 (Expression<Func<ReliefRequisitionDetail, bool>> predicate, Func<IQueryable<ReliefRequisitionDetail>, IOrderedQueryable<ReliefRequisitionDetail>> filter, string str) =>
                 {
                     return _reliefRequisitions.First().ReliefRequisitionDetails.AsQueryable();

                 }
            );

            mockUnitOfWork.Setup(t => t.ReliefRequisitionDetailRepository).Returns(
                mockReliefRequisionDetailRepository.Object);

            var mockTransportBidWinnerDetailRepository = new Mock<IGenericRepository<BidWinner>>();
            mockTransportBidWinnerDetailRepository.Setup(t => t.Get(It.IsAny<Expression<Func<BidWinner, bool>>>(), It.IsAny<Func<IQueryable<BidWinner>, IOrderedQueryable<BidWinner>>>(), It.IsAny<string>())).Returns(_transportBidWinners.AsQueryable());

            mockUnitOfWork.Setup(t => t.BidWinnerRepository).Returns(
                mockTransportBidWinnerDetailRepository.Object);

            mockUnitOfWork.Setup(t => t.ReliefRequisitionRepository).Returns(mockReliefRequisitionRepository.Object);
开发者ID:robela,项目名称:cats,代码行数:66,代码来源:TransportOrderServiceTests.cs

示例15: Init


//.........这里部分代码省略.........
                                         {
                                             new HubAllocation
                                                 {
                                                     RequisitionID = 1,
                                                     HubID = 1,
                                                     HubAllocationID = 1,
                                                     Hub=new Models.Hub()
                                                             {
                                                                 Name="Hub 1",
                                                                 HubID=1,

                                                             }
                                                 }
                                         };
            _transportRequisition = new TransportRequisition()
                                        {
                                            Status = 1,
                                            AdminUnit = new AdminUnit { AdminUnitID = 2,
                                                                      Name = "Zone1"},
                                            RequestedBy = 1,
                                            CertifiedBy = 1,
                                            CertifiedDate = DateTime.Today,
                                            RequestedDate = DateTime.Today,
                                            TransportRequisitionID = 1,
                                            TransportRequisitionNo = "T-001",
                                            Remark = "comment"
                                        };
            var mockReliefRequisitionRepository = new Mock<IGenericRepository<ReliefRequisition>>();
            mockReliefRequisitionRepository.Setup(
                t => t.Get(It.IsAny<Expression<Func<ReliefRequisition, bool>>>(), It.IsAny<Func<IQueryable<ReliefRequisition>, IOrderedQueryable<ReliefRequisition>>>(), It.IsAny<string>())).Returns(
                    (Expression<Func<ReliefRequisition, bool>> perdicate, Func<IQueryable<ReliefRequisition>, IOrderedQueryable<ReliefRequisition>> obrderBy, string prop) =>
                    {
                        var
                            result = reliefRequisitions.AsQueryable();
                        return result;
                    }
                );

            mockReliefRequisitionRepository.Setup(t => t.FindById(It.IsAny<int>())).Returns((int id) => reliefRequisitions
                                                                                                            .ToList().
                                                                                                            Find
                                                                                                            (t =>
                                                                                                             t.
                                                                                                                 RequisitionID ==
                                                                                                             id));
            unitOfWork.Setup(t => t.ReliefRequisitionRepository).Returns(mockReliefRequisitionRepository.Object);
            var transportRequisitionReqository = new Mock<IGenericRepository<TransportRequisition>>();

            transportRequisitionReqository.Setup(t => t.Add(It.IsAny<TransportRequisition>())).Returns(
                (TransportRequisition transportRequisiton) =>
                {
                    _transportRequisitions.Add(transportRequisiton);
                    return true;
                });
            transportRequisitionReqository.Setup(t => t.FindById(It.IsAny<int>())).Returns((int id) =>
            {
                return
                    _transportRequisition;
            });
            unitOfWork.Setup(t => t.TransportRequisitionRepository).Returns(transportRequisitionReqository.Object);
            unitOfWork.Setup(t => t.Save());

            var workflowStatusRepository = new Mock<IGenericRepository<WorkflowStatus>>();
            workflowStatusRepository.Setup(
                t =>
                t.Get(It.IsAny<Expression<Func<WorkflowStatus, bool>>>(),
开发者ID:FishAbe,项目名称:cats,代码行数:67,代码来源:TransportRequisitionServiceTests.cs


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