question

Hobbyistprogrammer-7674 avatar image
0 Votes"
Hobbyistprogrammer-7674 asked ·

Which is better and faster LINQ Query or Formula?

Hallo,

I just want to know the expert opinion on something I am planning to do. I have to write a method to determine cost of multiple objects . I can do this in two ways

  1. Make a table with list of items and costs ( so basically I get cost data from a table - aprox 2000 rows & 3 columns) then use LINQ to list of objects

  2. Create a polynomial function to calculate cost of an item ( at lease 10-20 lines of code depend on item)

what is better and faster?

Thanks



dotnet-visual-basic
10 |1000 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

karenpayneoregon avatar image
0 Votes"
karenpayneoregon answered ·

If values used in option two never change use this version while if values will change over time use option one.

·
10 |1000 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

Hobbyistprogrammer-7674 avatar image
0 Votes"
Hobbyistprogrammer-7674 answered ·

is there any performance difference between these two?

· 1 ·
10 |1000 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

Unknown without seeing the code as any code that works may or may not need optimization. For instance, if one was coding with Option Strict Off and depending on the runtime framework to figure things out vs using Option Strict On while another case might be using LINQ where LINQ may not be optimal or it may be, again hard to say. No matter I can't imagine there would be a huge difference between the two which if there is then we need to see the code.

0 Votes 0 ·