-6

I don't know the right words, so I will use a code example.

Class A {
    public MyList<MyModel> Models {
        get {
            // This won't work because it call's Models. How can I make this work??
            return Models.Load();
        };
    }
}

Class MyList<T> : List<T>{
    public List<T> Load(){
        return Something();
    }
} 

This is the thing I want to do:

var context = new A();
context.Models.Where(...);
Andreas Furster
  • 1,558
  • 1
  • 12
  • 28

2 Answers2

0

The best I can give you is if you are looking to implement LINQ into your classes, someone made a post here Adding LINQ to my classes

If you're looking to use an index for your class, there's a link here

Setting List items in C# without automatic setter/getter

But, unless you post an objective, and where you're hung up, there's not much we can help you with.

Community
  • 1
  • 1
Rachael Dawn
  • 819
  • 6
  • 13
0

Create a private field private MyList<MyModel> _model, initialze it, and return it in the Models property via _model.Load().

Moerwald
  • 10,448
  • 9
  • 43
  • 83