.Net MVC binding dynamic Type to a Model at runtime <p>I have a slightly long conceptual question I'm wondering if somebody could help me out with. </p> <p>In MVC I've built a website which builds grids using <a href="http://demos.kendoui.com/web/grid/index.html" rel="nofollow">kendoui's framework</a>. </p> <p>All the grids on my website are constructed exactly the same except for the model they use and the CRUD methods that need to be implemented for each model. I set things up where each Model implement an interface for CRUD methods like below to get the logic all in one place.</p> <pre><code>//Actual interface has variables getting passed public interface IKendoModelInterface { void Save(); void Read(); void Delete(); } public class Model1: IKendoModelInterface { [Key] public int IdProperty1 { get; set; } public int SomeProperty2 { get; set; } public string SomeProperty3 { get; set; } public void Save(){ //Implement Save } public void Read(){ //Implement Read } public void Delete(){ //Implement Delete } } </code></pre> <p>Then to speed up the writing of all the scaffolding Action methods needed to get the grids to work I created an abstract Controller that can call the interface methods of the Model that gets passed into it. </p> <pre><code> //Implement the AJAX methods called by the grid public abstract class KendoGridImplController&lt;T&gt; : Controller where T : class, IKendoModelInterface { // Method called from kendo grid public virtual ActionResult Create([DataSourceRequest] DataSourceRequest request, [Bind(Prefix = "models")]IEnumerable&lt;T&gt; createdRecords) { //Invoke Create Method for Model and return results } public virtual ActionResult Read([DataSourceRequest]DataSourceRequest request, int Id) { //Invoke read method for model and return results } //Update and Delete also implemented.. } </code></pre> <p>Then I just need a Controller per model that implements the abstract controller above passing in the type of Model being used.</p> <pre><code> public class ResponsibilityMatrixController : KendoGridImplController&lt;Model1&gt; { //Set up the page the grid will be on public ActionResult Index(int id) { return View("SharedGridView", id); } //Can override abstract methods if needed but usually won't need to } </code></pre> <p>I'm wondering if I can take this one step further or if I've reached the end of the road. To me it just seems like more repeated code if I have to create a controller per Model that does nothing but pass in the type to the abstract controller and calls the same View. </p> <p>I attempted for quite a while yesterday to figure out if I could dynamically assign the type to the abstract controller. I setup something where I was sending back the type of model via strings and I could still invoke the methods needed. Where it failed, was that the mapping could no longer be done on any of the controller actions by default since the type isn't known at compile time. eg </p> <pre><code>public virtual ActionResult Create([DataSourceRequest] DataSourceRequest request, [Bind(Prefix = "models")]IEnumerable&lt;T&gt; createdRecords) </code></pre> <p>createdRecords can't be bound like this if T that's passed in is an interface and not the Model itself and I've found no real way to map the form data to an instance of a type that isn't known at compile time. </p> <p>I'm wondering if there's an easy way to do this mapping between an instance of the type of object getting passed in that I can figure out at runtime, if there's some other way to set this up that I'm overlooking or if both those things are going to be way too much work and I should just not attempt something like this and build a controller per model like I do now? </p>