Simple c# MemoryCache mechanism to reduce number of db calls
This is a really bad pattern: neither your Student nor your School class should be responsible for retrieving themselves from the DB. Imagine retrieving a list of 100 Students: that would mean 100+ queries to the DB. You can't even apply filters (e.g. get all the Students who go to one School).

Your caching mechanism is solving the wrong problem. What you should do is:


Get all Schools and store them in a Dictionary&lt;int, School&gt; where the key is the Id of the School.
Get all Students, and then loop through them and attach the School based on the SchoolId.


Two queries instead of hundreds or thousands.