I have a web page that will make frequent calls to a data source. Instead of sending many calls to a database, I want to localize the set and then make the various controls query the local set using linq. I may be trying to do this all wrong, so I’m looking for some input.
private IEnumerable<entityFrameworkClass> _theList;
private IEnumerable<entityFrameworkClass> theList
{ set { _theList = from i in context select i;} get { return _theList; }}
Then in Page_Load
var yearQuery = from y in theList
select y;
I get an error that the source is null during debug.
Any ideas or maybe recommendations for a better method to accomplish this?
You are initializing the inner private variable
_theListin thesetoftheListproperty but when reading it, it’s thegetthat will be accessed (Properties in C#).What you want to do is this (Try also to write properties with CamelCase[Capitalization Conventions]):