I want to get my type from the database and then use a type variable to pass the type to the component. The reason why I'm not just strongly typing it is because we want to be able to switch the type in the database and it automatically reflects that in the website. User Server Side Blazor application.
//---GenericComponent---
@typeparam TItem
@code{
CustomClass<Titem> CustomClass {get;set;}
}
//---Razor---
@{
Type type = Type.GetType("DatabaseString");
<GenericComponent TItem="type" />
}
Is there anyway to accomplish this because the alternative that makes the most sense is to do a giant switch case where I call the component and hard code the TItem type using the string from the database as the switch.
You could try pass the list instance to child component. And use
Activatorto generate list instance.GenericComponent.razor