Returns the .Take() method and IEnumerable<T> , not List<T> . This is good, and you should seriously consider changing your method and your work habits to use IEnumerable<T> rather than List<T> as much as possible.
In addition, .Take(100) will also return the first 100 elements, not the last 100 elements. You want something like this:
public IEnumerable<Model.PIP> GetPIPs() { if (Repository.PIPRepository.PIPList == null) Repository.PIPRepository.Load(); return Repository.PIPRepository.PIPList.Skip(Math.Max(0,Repository.PIPRepository.PIPList.Count - 100)); }
If you really need a list rather than an enumerable (hint: you probably aren't), it's even better to create this method with IEnumerable and use .ToList() at the place where you call this method.
At some point in the future you will want to come back and update your Load () code to use IEnumerable as well as the code in the future. The ultimate goal here is to get to the point that you efficiently transfer your objects to the browser, and only one of them is loaded into memory on your web server at a time. IEnumerable allows this. Not listed.
source share