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


C# IQueryable.Concat方法代码示例

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


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

示例1: EmployerControllerTest

        public EmployerControllerTest()
        {
            _data = new List<Employee>
            {
                new Employee {EmployeeID = 1,  Name = "Aimen", Address = "Address" , Age = 1, Employment = 1, Active = 1},
                new Employee {EmployeeID = 2,  Name = "Max", Address = "Address" , Age = 1, Employment = 1, Active = 1},
                new Employee {EmployeeID = 3,  Name = "Alex", Address = "Address" , Age = 1, Employment = 1, Active = 1},
            }.AsQueryable();

            _mockSet = new Mock<DbSet<Employee>>();
            _mockSet.As<IQueryable<Employee>>().Setup(m => m.Provider).Returns(_data.Provider);
            _mockSet.As<IQueryable<Employee>>().Setup(m => m.Expression).Returns(_data.Expression);
            _mockSet.As<IQueryable<Employee>>().Setup(m => m.ElementType).Returns(_data.ElementType);
            _mockSet.As<IQueryable<Employee>>().Setup(m => m.GetEnumerator()).Returns(_data.GetEnumerator());

            _mockER = new Mock<IEmployeeRepository>();
            _mockER.Setup(t => t.Get()).Returns(_mockSet.Object);
            _mockER.Setup(t => t.Get(x => x.EmployeeID == It.IsAny<int>())).Returns(_mockSet.Object);
            _mockER.Setup(t => t.Add(It.IsAny<Employee>())).Callback((Employee employee) =>
            {
                var newListEmployee = new List<Employee> { employee };
                _data = _data.Concat(newListEmployee);
            }).Verifiable();
            _mockER.Setup(t => t.Delete(It.IsAny<Employee>())).Callback((Employee employee) =>
            {
                //var newListEmployee = new List<Employee> { employee };
                var list = new List<Employee>();
                list = _data.ToList();
                list.Remove(employee);
                _data = list.AsQueryable();
            }).Verifiable();
            //_mockER.Verify(mr => mr.Update(It.IsAny<Employee>()), Times.Once());
            //_mockER.Setup(t => t.Delete(It.IsAny<int>()));
            //_mockER.Setup(t => t.Delete(It.IsAny<Employee>()));
            _mockER.Setup(t => t.Update(It.IsAny<Employee>()));

            _mockUW = new Mock<IUnitOfWork>();
            _mockUW.Setup(t => t.SaveChanges());

            _mockHttpContext = new Mock<HttpContextBase>();
            _mockRequest = new Mock<HttpRequestBase>();
            _FormKeys = new NameValueCollection();
            _mockHttpContext.Setup(ctxt => ctxt.Request).Returns(_mockRequest.Object);
            _mockRequest.Setup(r => r.Form).Returns(_FormKeys);
        }
开发者ID:iqbal001001,项目名称:Business,代码行数:45,代码来源:EmployerControllerTest.cs

示例2: GetRelatedPeopleUnionQuery

 /// <summary>
 ///     Add a Query to an existing Query to create a Union Query.
 /// </summary>
 /// <param name="query"></param>
 /// <param name="unionQuery"></param>
 private IQueryable<RelatedPersonInfo> GetRelatedPeopleUnionQuery( IQueryable<RelatedPersonInfo> query, IQueryable<RelatedPersonInfo> unionQuery )
 {
     return ( query == null ? unionQuery : query.Concat( unionQuery ) );
 }
开发者ID:,项目名称:,代码行数:9,代码来源:

示例3: Concat

 private IQueryable<PublisherDO> Concat(IQueryable<PublisherDO> first, IQueryable<PublisherDO> second)
 {
     if (first == null)
     {
         return second;
     }
     else
     {
         return first.Concat(second);
     }
 }
开发者ID:MartinBG,项目名称:Gva,代码行数:11,代码来源:PublisherRepository.cs


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