Since this week has been a lost cause (I slept last night--huzzah!--but had too much scheduled to do today for writing), I've been reading a book called Lord Darcy by Randall Garrett. Lord Darcy is actually an omnibus volume containing Garrett's various stories about a guy named--you guessed it--Lord Darcy.
It was very entertaining to me as a reader, but it was also really interesting to me as a writer, because the Lord Darcy stories are probably the only truly successful marriage of the mystery genre and the science fiction/fantasy genre that I've ever read.
The problem with most other attempts at amalgamating those two genres is that mystery novels are basically puzzles--here's a dead body, let's figure out how it got there. Puzzles work because of there are limitations on the puzzle-solver, who doesn't just know all the answers but has to sort it out using only partial and often unreliable information.
Science fiction and fantasy, however, are genres where human limitations are usually greatly reduced or utterly eliminated through technology or magic. So they usually don't mix well with mystery: The wizard waves his wand or the robot taps into the database, and the problem is magically (and boringly) solved!
So limits have to be put on these things. In the Vorkosigan Saga (which is not strictly mystery, but there are occasional crimes as well as a great deal of espionage), there's a truth serum called fast-penta. But it doesn't work in everybody, some people are deathly allergic, and some people have been made deathly allergic specifically so they can't be interrogated.
Garrett handles this issue by having the magic be extremely rules-based and quite limited--it is, in the alternative history of Lord Darcy's world, scientific. Magic that would be really inconvenient in a mystery novel, like teleportation, simply doesn't exist. Instead, much of the magic revolves around the principle that things that were once whole wish to be whole again. So, for example, a forensic sorcerer (yes, that's a thing) could take blood from the scene of a crime and blood from a suspect, smear them on the opposite sides of a dish, and cast a spell. If it's the same blood, it will pool together, and you've placed your suspect at the scene.
It's very clever because it lets the investigators know some things (whose blood is that, what gun did that bullet come from) without knowing all things.
If it sounds like forensic sorcerers aren't much more useful than forensic scientists, well, they're not. And Garrett goes even further: Because magic is scientifically understood, actual science--chemistry, physics, biology--isn't understood very well at all, so technology has suffered greatly. While the books are set in the years Garrett wrote them, the technology mostly comes from the previous century. Far from magic being something that solves all problems, magic is something that has effectively created more limits.
For example, at one point Lord Darcy is secretly searching a room at night with the help of "a special device."
It was a fantastic device, a secret of His Majesty's Government. Powered by little zinc-copper couples that were the only known source of such magical power, they heated a steel wire to tremendously high temperature. The thin wire glowed white-hot, shedding a yellow-white light that was almost as bright as a gas-mantle lamp. The secret lay in the magical treatment of the steel filament. Under ordinary circumstances, the wire would burn up in a blue-white flash of fire. But, properly treated by a special spell, the wire was passivated and merely glowed with heat and light instead of burning. The hot wire was centered at the focus of a parabolic reflector, and merely by shoving forward a button with his thumb, Lord Darcy had at hand a light source equal to--and indeed far superior to--an ordinary dark lantern.
That's just so wonderful on so many levels. Not only is a plain old flashlight a source of awe (you merely have to shove forward a button with your thumb!), but it's repeatedly compared with things the reader isn't familiar with (various lamps and lanterns), because of course in Lord Darcy's world, that's what used. My most-favorite bit is the fact that they solve the major engineering puzzle of the incandescent bulb--how do you prevent the filament from just burning up?--by using magic. Of course. Because that's what they use to solve all their problems. It just doesn't work that well.