"I often say that Castle is Moonlighting meets Murder, She Wrote having not really remembered Moonlighting and never having actually seen Murder She Wrote."Castle is a Police Procedural dramedy starring Nathan Fillion and Stana Katic.Fillion plays famous mystery novelist Richard Castlenote , who begins the series having killed off his most famous character and suffering from a severe case of writer's block.After a killer begins to recreate murder scenes from Castle's books, Castle is consulted by Detective Kate Beckett (Katic) of the NYPD. When an obsessive fan is arrested far too quickly and easily, it bothers his writer's sensibilities, convincing him that the fan was framed and helping Beckett to catch the real murderer.Enamoured with using his knowledge of criminal methodology to solve real crimes (and a bit more enamoured with Beckett, who becomes the inspiration for his next main character), Castle pulls some strings and gets permission to work alongside Beckett and the NYPD as "research" for his next book. With Castle's analytical instincts and Beckett's years of experience, They Fight Crime.An interview with Fillion providing a lot of relevant information can be found here. The show also has its own wiki.
—Nathan Fillion as quoted here
Has a recap page.
This series provides examples of: