I would like to create a procedure that returns everything dynamically so that I don't have to develop a switch on string to find the correct type. I tried to get a type from a string:
Type myDynamicType = Type.GetType("myDynamicType");
var objects = dataContext.Database.SqlQuery<myDynamicType>($"SELECT * FROM MY_TABLE WHERE Id > 0").ToList();
This code doesn't work because return this error:
Error CS0118 'myDynamicType' is a variable but is used like a type
Aucun commentaire:
Enregistrer un commentaire