2
Hello! I need to make a query in the database, the scenario is as follows: I receive email
and from it I seek the id
user. About the bank, there is the table Contact
, which has Nxn relationship with the table user
. So far I’ve done it this way:
var result = _context
.Clients
.Where(x => x.Contacts.First().Email.Equals(email))
.AsNoTracking()
.ToList();
var id = result
.Select(x => x.Id)
.First()
.ToString();
However, I think that in this consultation that I did could be being long-winded and could be done in a better way, even in a single query to the bank (I did 2 in this example). Could someone make a suggestion?