I have the below code I would like to adapt because it is calling multiple times on a lengthy event that I think could be avoided:
People= (from p in xDocument.Root.Descendants("People").Where(
se => Get<int>(se.Element("ID")) != i1)
select new Person
{
ID = Get<int>(se.Element("ID")),
Skills = GetPersonSkills(Get<int>(se.Element("ID")))
}).OrderBy(w => w.FirstName).ToList()
How can I, instead of having the application rerun the Get(se.Element("ID")) method, just simply tell Skills = GetPersonSkills(ID). It would then just simply read its own ID value.
PS: The code I wrote here is not the actual lengthy code but simplified to demonstrate the purpose. I am aware that my Get(se.Element("ID")) example is not time consuming for the application but it was just to highlight the part of teh code that i would need to improve.