public async Task <IActionResult> Index() { // Main slides home var filterMainSlide = Builders <Slide> .Filter.Eq(x => x.SlideType, StaticVar.MainSlide); var filterSubSlide = Builders <Slide> .Filter.Eq(x => x.SlideType, StaticVar.SubSlide); ViewBag.Slides = await _slide.FilterByAsync(filterMainSlide); ViewBag.SubSlides = await _slide.FilterByAsync(filterSubSlide); // Join with customer to show avatar !!??? var collectionComment = _comment._collection; var comments = collectionComment.Aggregate() .Lookup("CustomerTest", "Customer", "_id", "ObjCustomers") .As <Comment>() .ToList(); ViewBag.Comments = comments; // Blogs var news = _news.AsQueryable().Where(x => x.IsActive == true).OrderByDescending(x => x.Id).Take(2); ViewBag.News = news; // Books var books = _book.AsQueryable().Where(x => x.IsActive == true).OrderByDescending(x => x.Id).Take(8); ViewBag.Books = books; return(View()); }
SearchFor(Expression <Func <T, bool> > predicate) { return(entityRep .AsQueryable <T>() .Where(predicate.Compile()) .ToList()); }
public void AsQueryable_InserThreeItem_ReturnTwo() { var repository = new MongoRepository<TestModel4>(); repository.Drop(); repository.Insert(new TestModel4 { StringValue = "sinan" }); repository.Insert(new TestModel4 { StringValue = "sinan" }); repository.Insert(new TestModel4 { StringValue = "ali" }); var list = repository.AsQueryable().Where(x => x.StringValue == "sinan"); Assert.AreEqual(2, list.Count()); }
public PagedResult <Stock> List([FromUri] PagedFilter filter) { var query = _stockRepository.AsQueryable(); return(PagedResult <Stock> .From(query, filter)); }
// Test data public IActionResult Category() => Json(_category.AsQueryable());