Is it appropriate for a lecturer to invite the course to dinner before grading?
I think it's completely appropriate.

As an anecdote, when I was an undergrad I was in a similar situation. The professor of a WW2 history class I was taking invited all 20-or-so of us undergrads to his home for a barbecue and tour of his collection of WW2 era guns, equipment, newspaper clippings, and so on. It occured before final grades came out.

In hindsight, it was one of those great lasting memories you make in school. I ended up majoring in a different field, but have since still kept a keen interest in history because, at least in part, of the experience I had there. Had that professor decided not to have such an event I would absolutely consider my undergraduate experience to be lesser than it was, and I think the same is true for many of my classmates both in that year and every other year the professor held such an event. 



We, of course, don't know you or your lecturer, but I would be absolutely shocked if he has anything but pure intentions. If you don't want to go just reply to the invitation that you've got a prior commitment and can't make it. 

Given you know that this lecturer has had this event in the past (after grades) indicates that it's almost assuredly done with positive intentiontions. Perhaps this year he has to travel immediately after he finishes grades, or the school scheduled his final later than last year and he has less time than normal. Maybe he's done it after grades in the past and had low attendance from foreign students who often have to travel right immediately and he wants to include them as well.