How to remove duplicate matching?
Just expose the class types to the user (which they already appear to be) rather than forcing them to use a gawd-awful enum.

public class Module
{
  public string GetXml&lt;TShape&gt;( int id ) where TShape : Shape
  {    
    return DB.GetEntity( id ).ToTypedEntity&lt;TShape&gt;().ToXml();    
  }
}


The the user can just make a normal call like

new Module().GetXml&lt;Triangle&gt;(34);