I have an EF4.Model with Category
table which will be using the NestedSet
pattern to store child/parent relation, which I think means that EF4 cannot help with its factory methods in retrieving the children becoz there will be no children or parentId
, just left and right.
I created an CategoryMod开发者_Go百科elExtensions
static class, but for the children to be retrieved I will need a variable to refer to the repository.
But how can I inject that variable when constructors are not allowed in static classes?
I didn't want to create the Children() method in the repository for I want to be able to write.
Category c = _repo.Get(1);
IList<Category> children = c.Children();
Help? If my question is not clear please mention it here and I will update it as needed.
You could just pass it explicitly:
public static IList<Category> Children(this Category category, IMyRepository<Category> categories)
{
// do stuff
}
IList<Category> children = c.Children(_repo);
精彩评论