public async Task <QueryResult <Person> > AllAsync(QueryPerson filter) { var query = _context.Persons.AsQueryable(); if (!string.IsNullOrEmpty(filter.First)) { query = query.Where(p => p.FirstName.ToUpper().StartsWith(filter.First.ToUpper())); } if (!string.IsNullOrEmpty(filter.Last)) { query = query.Where(p => p.LastName.ToUpper().StartsWith(filter.Last.ToUpper())); } var filterMap = new Dictionary <string, Expression <Func <Person, object> > >() { ["first"] = p => p.FirstName, ["last"] = p => p.LastName, ["id"] = p => p.Id }; return(new QueryResult <Person>() { TotalItems = await query.CountAsync(), Items = await query .OrderBy(filter, filterMap) .Paginate(filter) .ToListAsync() }); }
public ActionResult QueryPerson(QueryPerson model) { if (!IsLogin) { return(View()); } using (blogEntities en = new blogEntities()) { var result = from user in en.Users where !Passport.AccountID.Equals(user.UserID) && user.UserID.Contains(model.Keyword) || user.FirstName.Contains(model.Keyword) || user.LastName.Equals(model.Keyword) || user.FirstNamePy.Equals(model.Keyword) || user.LastNamePy.Equals(model.Keyword) select new PersonInfo() { Age = 20, DisplayName = user.FirstName + user.LastName, Name = user.UserID, Sex = user.Sex }; model.Persons = result.ToList(); } return(View(model)); }
public void TestQueryEntityConfiguration() { var cfg = new IgniteConfiguration { JvmOptions = TestUtils.TestJavaOptions(), JvmClasspath = TestUtils.CreateTestClasspath(), BinaryConfiguration = new BinaryConfiguration(typeof (QueryPerson)), CacheConfiguration = new[] { new CacheConfiguration(CacheName, new QueryEntity(typeof (int), typeof (QueryPerson)) { Fields = new[] { new QueryField("Name", typeof (string)), new QueryField("Age", typeof (int)) }, Indexes = new[] { new QueryIndex(false, QueryIndexType.FullText, "Name"), new QueryIndex("Age") } }) } }; using (var ignite = Ignition.Start(cfg)) { var cache = ignite.GetCache<int, QueryPerson>(CacheName); Assert.IsNotNull(cache); cache[1] = new QueryPerson("Arnold", 10); cache[2] = new QueryPerson("John", 20); using (var cursor = cache.Query(new SqlQuery(typeof (QueryPerson), "age > 10"))) { Assert.AreEqual(2, cursor.GetAll().Single().Key); } using (var cursor = cache.Query(new TextQuery(typeof (QueryPerson), "Ar*"))) { Assert.AreEqual(1, cursor.GetAll().Single().Key); } } }
public ActionResult QueryPerson() { base.ValidationLogin(); QueryPerson model = new QueryPerson(); using (blogEntities en = new blogEntities()) { var result = from user in en.Users select new PersonInfo() { Age = 20, DisplayName = user.FirstName + user.LastName, Name = user.UserID, Sex = user.Sex }; model.LoginUser = base.Passport; model.Persons = result.ToList(); } return(View(model)); }
protected void btnLogin_Click(object sender, EventArgs e) { QueryPerson query = new QueryPerson(); Collection <Person> test = query.GetPersons(); }
public async Task <QueryResult <Person> > Get([FromQuery] QueryPerson filter) { return(await _repo.AllAsync(filter)); }