EF4. Add a object with relationship causes full table select
Posted
by Fujiy
on Stack Overflow
See other posts from Stack Overflow
or by Fujiy
Published on 2010-05-21T01:27:03Z
Indexed on
2010/05/21
1:30 UTC
Read the original article
Hit count: 312
Ex 1:
"autor.ComentariosWorkItens.Add(comentarioWorkItem);"
autor.ComentariosWorkItens makes EF4 load all ComentariosWorkItens.
Ex 2:
comentarioWorkItem.Usuario = autor;
Fixup make EF load all ComentariosWorkItens too:
private void FixupUsuario(Usuario previousValue)
{
if (previousValue != null && previousValue.ComentariosWorkItens.Contains(this))
{
previousValue.ComentariosWorkItens.Remove(this);
}
if (Usuario != null)
{
if (!Usuario.ComentariosWorkItens.Contains(this))
{
Usuario.ComentariosWorkItens.Add(this);
}
}
}
How can I prevent this?
© Stack Overflow or respective owner