示例#1
0
		public ActionResult List(string namePrefix = null, string role = null)
		{
			IQueryable<ApplicationUser> applicationUsers = new ULearnDb().Users;
			if (!string.IsNullOrEmpty(namePrefix)) applicationUsers = applicationUsers.Where(u => u.UserName.StartsWith(namePrefix));
			if (!string.IsNullOrEmpty(role)) applicationUsers = applicationUsers.Where(u => u.Roles.Any(r => r.Role.Name == role));
			return View(applicationUsers.OrderBy(u => u.UserName).Take(50).ToList());
		}