If you create a context
for each object, as in the first example, you will have problem if the objects are associated, example: Pessoa
and Endereco
, where Endereco
points to Pessoa
. So, when you have an instance of Pessoa
in a context
and an instance of Endereco
in another context
and need to turn on this Endereco
à Pessoa
, will give error saying that can not because they are part of contexts
different.
As in the second example, it is only possible if you can solve everything in one method. Horrible! Example: I can have a method that searches person by Cpf.
Pessoa.pesquisaCpf(string cpf)
In this method I return a person and need to do a search using a context
. Then I need to create a Endereco
, using my same example, and I use the Address constructor, which will create another context. It will already give error.
To solve all this I’m still using only one context
created in the system login. I am not happy with this, because the changes made in the system by one user are not seen by another user on another machine, until the same rewrites the login. This I’m trying to fix.
Thanks, @Gypsy! Too bad I can only choose one answer, because yours was very good too.
– Tiago César Oliveira
No problem. The important thing is to contribute ;)
– Leonel Sanches da Silva