I am trying to create and use an instance of a class dynamically but keep running into the error " a is a variable but used as a type".
//First we need to find the project that holds all of our entity models in the assembly
var assembly = AppDomain.CurrentDomain.GetAssemblies()
.Where(x => x.FullName.Contains("MyProject.Models"))
.FirstOrDefault();
//Now we need to search through the assembly to match the Entity to the supplied TableName
var type = assembly.GetTypes()
.FirstOrDefault(t => t.Name == localTableName);
var a = Activator.CreateInstance(type);
Why can't I use this like so
List<a> dynamicList = new List<a>;
or what I need to do this
var query = context.Database.SqlQuery<a>(...);
In that duplicate that you have linked it just translates a list. I may not need a list I may need the class to use in a SQLQuery