I have this LinQ:
var IPI = item.INV_TAXES.Where(t => t.TAXTYPES.TAXNAME == "IPI")
.Select(t => new {TOT_AMT = t.TAXVALUE, t.TAXFACTOR, t.TAXBASE})
.First();
Then after in the code I call the next lines about 10 times:
PerformSomeCalculation(IPI.TOT_AMT);
PerformAnotherStuff(IPI.TOT_AMT,IPI.TAXVALUE);
PerformSomethingElse(IPI.TAXBASE);
I wonder if everytime that I call each member of IPI, the LinQ executes or just the first time when I assign it?
Is it better to assign the IPI members to a variable first?
decimal IPI_TOT_AMT = IPI.TOT_AMT,
IPI_TAXVALUE = IPI.TAXVALUE,
IPI_TAXBASE = IPI.TAXBASE;
And then use them.
Thanks for all the advises.