I am using the following code to allow for users to search for other registered users in order to add them to a friends list:
[Authorize(Roles = "RegisteredUsers")]
public ActionResult Index(string searchString)
{
//list of registered users
var regUsers = db.Users;
if (!String.IsNullOrEmpty(searchString))
{
regUsers = regUsers.Where(s => s.User.LastName.Contains(searchString));
}
return View(regUsers.ToList());
}
Yet I am getting an error on line 9 at regUsers = regUsers.Where(..)
, stating:
"cannot implicitly convert type
System.Linq.IQueryable<ETLToolKit.Models.User>
toSystem.Data.entity.DbSet<ETLToolKit.Models.User>
How can I reuse the regUsers
variable?