This question is locked. New answers and comments are not allowed.
Hi,
I need delete records from few related tables:
should be deleted all child records from tablea, then tableb then tablec and at the end should be deleted resource.
unfortunately order of deleting is diferent and I have error message that record can't be deleted becouse related child records are exist.
Is it possible to have control about order of deleting operations?
Thanks.
Leszek
I need delete records from few related tables:
//delete all related fields
var valuesForDelete = from v in dbc.tablea
where v.resource_id== id
select v;
dbc.Delete(valuesForDelete);
var listValuesForDelete = from lv in dbc.tableb
where lv.RESOURCE_ID == id
select lv;
dbc.Delete(listValuesForDelete);
var fieldsForDelete = from f in dbc.tablec
where f.RESOURCE_ID == id
select f;
dbc.Delete(fieldsForDelete);
var resourceForDelete = from r in dbc.resources
where r.ID == id
select r;
dbc.Delete(resourceForDelete);
dbc.SaveChanges();
should be deleted all child records from tablea, then tableb then tablec and at the end should be deleted resource.
unfortunately order of deleting is diferent and I have error message that record can't be deleted becouse related child records are exist.
Is it possible to have control about order of deleting operations?
Thanks.
Leszek