I just want to get the user’s role and ID from the user table. But I do not know why the following code gives an error!!!
public Tuple<Guid,Guid> GetUserId(string mobile)
{
return _context.Users.Select(u => new Tuple<Guid,Guid,Boolean>(u.UserId,u.RoleId,u.Mobile == mobile));
}
I searched a lot but did not find an answer?
Error:
>Solution :
Meanwhile, your existing code will return IEnumerable<Tuple<Guid,Guid>> or IQueryable<Tuple<Guid,Guid>>, which un-match with the method return type, Tuple<Guid,Guid>.
Assume that you are trying to filter with mobile.
You need either of these methods:
to return (single) result Tuple<Guid,Guid>.
public Tuple<Guid,Guid> GetUserId(string mobile)
{
return _context.Users
.Where(u => u.Mobile == mobile)
.Select(u => new Tuple<Guid,Guid>(u.UserId,u.RoleId))
.First();
}
