I want to search for users in my db and create new types in the WHERE statement. But when i do this i cant add the Range in my List for the return.
I get the error in "AllUsers.AddRange(user);"
var AllUsers = new List<string>();
var url = "https://localhost:44356/";
string[] namelist = name.Split(" ");
foreach (var n in namelist)
{
var user = await context.Users.Where(r => r.FirstName.ToLower().Contains(n) || r.LastName.ToLower().Contains(n)).Select(
u => new
{
id = u.Id,
Name = u.FirstName + u.LastName,
Beschreibung = u.Description,
Avatar = url + u.ProfileImagePath.Remove(0, 58),
Header = url + u.HeaderImagePath.Remove(0, 58),
}).ToListAsync();
AllUsers.AddRange(user);
}
var mitglieder = AllUsers.Distinct().ToList();
return Ok(mitglieder);
useris adynamiclist, which means you cannot add it into a string list. Either, you convert it toJSONto make it string or you make theAllUserslist adynamiclist instead astringbased list.