Best way to populate a list (or something) and make several methods use it?
<p>I have a console application with a few methods that:</p>

<pre><code>insert data1 (customers) from db 1 to db 2
update data1 from db 1 to db 2
insert data2 (contacts) from db 1 to db 2
insert data2 from db 1 to db 2
</code></pre>

<p>and then some data from db 2 (accessed by web services) to db 1 (MySql), the methods are initialized on execution of the application.
With these inserts and updates I need to compare a field (country state) with a value in a list I get from a web service. To get the states I have to do:</p>

<pre><code>GetAllRecord getAllStates = new GetAllRecord();
getAllStates.recordType = GetAllRecordType.state;
getAllStates.recordTypeSpecified = true;
GetAllResult stateResult = _service.getAll(getAllStates);
Record[] stateRecords = stateResult.recordList; 
</code></pre>

<p>and I can then loop through the array and look for shortname/fullname with</p>

<pre><code>if (stateResult.status.isSuccess)
{
    foreach (State state in stateRecords)
        {
            if (addressState.ToUpper() == state.fullName.ToUpper())
                            {
                                addressState = state.shortname;
                            }
                }
}
</code></pre>

<p>As it is now I have the code above in all my methods but it takes a lot of time to fetch the state data and I have to do it many times (about 40k records and the web service only let me get 1k at a time so I have to use a "searchNext" method 39 times meaning that I query the web service 40 times for the states in each method.</p>

<p>I guess I could try to come up with something but I'm just checking what best praxis would be? If I create a separate method or class how can I access this list with all its values many times without having to download them again?</p>

<pre><code>Edit: should I do something like this:
            GetAllRecord getAllStates = new GetAllRecord();
            getAllStates.recordType = GetAllRecordType.state;
            getAllStates.recordTypeSpecified = true;
            GetAllResult stateResult = _service.getAll(getAllStates);
            Record[] stateRecords = stateResult.recordList;

            Dictionary&lt;string, string&gt; allStates = new Dictionary&lt;string, string&gt;();
            foreach (State state in stateRecords)
            {
                allStates.Add(state.shortname, state.fullName);
            }
</code></pre>

<p>I am not sure where to put it though and how to access it from my methods.</p>
