ExampleOmitted headOriginal caseExpressed case
وَجَاءَ رَبُّكَأَمْررَبِّ — genitiveرَبُّ — nominative
وَاسْأَلِ الْقَرْيَةَأَهْلالْقَرْيَةِ — genitiveالْقَرْيَةَ — accusative
Both examples work through deletion of the head of annexation. The surviving genitive complement takes a new place in the sentence, but that place is nominative in one example and accusative in the other.
Correct analysis therefore requires two questions in order: “Was a word omitted or added?” and “What syntactic function does the surviving word now perform?”