Whenever facing hordes of melee (melee only), I order my squad into the open beside me. They fire much more frequently when in the open, meaning less melee enemies get close enough to deal any damage. Also, when ordered to stand close to you, it prevents them from executing their "run off, get swarmed and die" routine. Granted, this strategy is only used about four or five times throughout the entire game, but it's useful enough during those times to warrant mentioning. Should go without saying, but you want to ensure they're using their best weapon for dealing with melee units, as they tend to slack on this as well.