I'm making a generic grid component in blazor c# to handle CRUD operations and master detail relations.
now I have two generic components
public class GridM<TParentModel> where TParentModel : new() { // My code }
and I have
public class GridD<TParentModel,TChildModel> : GridM<TChildModel>where TParentModel : new()
{
// here I'm overriding some methods from the parent class to handle relational stuff
}
so for plain tables I'm using GridM to display my data and when I have 1 to many relations with the master table I'm using GridD to display the relational data.
so far so good, I do not have any issues with the above approach. Then after putting some thoughts on this approach I've decided to merge GridM and GridD into one class like this:
public class MyGrid<TModel> {}
public class MyGrid<TModel, TChild> : MyGrid<TChild>{ // and override methods here }
this in theory works fine and assuming these implementations were not components I would be able to initialize them like
var a = new MyGrid<Users>();
var b = new MyGrid<Users,Orders>();
so when I try to use this component like
< MyGrid TModel="UserModel"> </MyGrid >
I get the following error:
The component 'MyGrid' is missing required type arguments. Specify the missing types using the attributes: 'TChildModel'.
because blazor does not now whether I'm using MyGrid<TModel> or MyGrid<TModel,TChildModel>.
my question is how can I make blazor understand this?
