I haven't managed to save everyone, but I saved most of them.
Key things--cast Heal on the militia who are badly hurt, let your tank use pots to heal. Force field can also save militia members who are swarmed (as well as absorbing a lot of blows from enemies). I just wish that Group Heal would also work on the Militia
With my first party, Alistair didn't have Taunt. I assume that this will help quite a bit to take heat off the militia.
Use lots of crowd control spells to keep the corpses frozen/paralyzed/stunned. Mind blast is great in this fight because it only effects enemies. I'd definitely recommend bringing two mages to this fight if you can (both should have heal).
You can also use AOE spells on the area outside the barricade where the new corpses come from to soften them up.