I have records in the database (for example, clients), and all records have a EmpresaID
identifier. I'm using identity
with entity framework to authenticate. In the user's registry I have an identifier "CompanyId".
I would like to know how to bring only the records that EmpresaId
of the client is equal to EmpresaId
of the user in the code below:
public ActionResult Index()
{
Empresa empresa = new Empresa();
RegisterViewModel usuario = new RegisterViewModel();
var exames = db.Exames.Include(p => p.Empresa);
return View(db.Exames.ToList());
}
Currently it brings all the records:
public ActionResult Index()
{
Empresa empresa = new Empresa();
RegisterViewModel usuario = new RegisterViewModel();
var exames = db.Exames.Include(p => p.Empresa);
return View(db.Exames.ToList());
}