Page 1 of 1

LINQ Remove

Posted: Tue 27 Oct 2009 09:22
by halley73to
Hi,
why the Remove form a child collection perform an update on the child setting the id of the parent to 0 and not the delete?

UPDATE MAGAZZINO.A_RIGHE_ORDINE SET ID_ORDINE = :p1 WHERE ID_RIGA_ORDINE = :key1 AND ID_ORDINE = :key2 AND ID_PRODOTTO = :key3 AND QUANTITA = :key4 AND QUANTITA_EVASA = :key5 AND ID_STATO_RIGA_ORDINE = :key6 AND ((:nullkey7 = 1 AND IMPORTO IS NULL) OR (IMPORTO = :key7)) AND OMAGGIO = :key8 RETURNING ID_ORDINE, ID_PRODOTTO, QUANTITA, QUANTITA_EVASA, ID_STATO_RIGA_ORDINE, IMPORTO, OMAGGIO, NOTE INTO :ret1, :ret2, :ret3, :ret4, :ret5, :ret6, :ret7, :ret8
ParameterName = p1
DbType = Decimal
Value = 0
ParameterName = key1
DbType = Decimal
Value = 6
ParameterName = key2
DbType = Decimal
Value = 1
ParameterName = key3
DbType = Decimal
Value = 84
ParameterName = key4
DbType = Decimal

Thanks, Luca

Posted: Fri 30 Oct 2009 15:54
by AndreyR
If you make Parent.ChildCollection.Remove(Child instance), you simply set the foreign key to null in this case.
To delete the child object you should explicitly delete it from DataContext.Children EntitySet
using theDeleteOnSubmit method.