Being relatively new to the .net game, I was wondering if anyone has experience with the pros and cons between using LINQ and what can be considered more traditional methods of working with lists / collections?
For a specific example of the project I'm working on: the list of remote web services is retrieved from the list of unique id / name pairs.
- this list will change infrequently (once a day),
- will be read-only in terms of the application in which it is used.
- will be stored at the application level for all requests to access
Given these points, I plan to keep the return values ββat the application level in a singleton class.
My initial approach was to iterate over the list returned from the remote service and store it in NameValueCollection in a singleton class, with methods for retrieving from the collection based on identifier:
sugarsoap soapService = new sugarsoap(); branch_summary[] branchList = soapService.getBranches(); foreach (branch_summary aBranch in branchList) { branchNameList.Add(aBranch.id, aBranch.name); }
An alternative using LINQ is to simply add a method that works in the list immediately after receiving it:
public string branchName (string branchId) {
Better than the other - is there a third way? I am open to all the answers, both for both approaches, and for solutions that offer elegance, and those that benefit productivity.
source share