the following code returns all information of table if credentials matches. But I want to write another query inside else condition block where it will return me only specific columns of admins table, for example Email, Name, and Role. How can I do that?
Admin adminLoggedin = db.Admins.SingleOrDefault(x => x.Email==model.Email && x.Password == model.Password);
if (adminLoggedin == null)
{
return BadRequest();
}
else
{
// ***Query2 select Email , Name, RoleId from Admins Where Email = adminLoggedin.Email
// how to write this query with Entity framework and ado.net model
FormsAuthentication.SetAuthCookie(model.Email, model.RememberMe);
return Ok(adminLoggedin);
}