public static void DeleteByDamage(int id) { using (var unitOfWork = new UnitOfWork()) { using (var items = new XPCollection <DB.OrderDamages>(unitOfWork)) { var dbItems = items.Where(u => u.Damage.Id == id).ToArray(); items.DeleteObjectOnRemove = true; for (var i = 0; i < dbItems.Length; i++) { var dbItem = dbItems[i]; Damages.Delete(dbItem.Damage.Id, unitOfWork); items.Remove(dbItem); } } unitOfWork.CommitChanges(); } }