Hi, I have a column called Product Code and a corresponding field called Todays Stock. The file has over 15,000 lines so a for each takes ages.
Is there a LINQ query to help me find the todays stock value using the product code? That returns a value and returns something else if it cannot find it?
I’m trying to learn a bit of LINQ also so if you could explain the answer also I would greatly appreciate it
I believe Todays Stock is a row value and corresponding to it you would require the Product Code column’s value. If that is the case, then you can check with the below Expression :
In the above Expression, we have assumed that the row value Todays Stock will be present in the First Column, and hence we have used the index 0.
For Learnings on Linq, You could check the below Posts :
Do Also note that, we have assumed your data representation also, If you could provide us with the Data format or Representation then we could confirm the working.
I have a value I will input which will be a code, using this code I need to get the value that is within the todays stock field, so for example if my input was 000892 I would need my output to be 8
This is the code I am using to convert to dictionary - DT_codes.AsEnumerable.ToDictionary(Function (x) x(“Product Code”).toString.Trim, Function (x) x(“Available Physical Stock - Today”).toString.Trim)
This is the code that is giving me an error - This is what I am using DT_codes.AsEnumerable.ToDictionary(Function (x) x("Product Code").toString.Trim, Function (x) x("Available Physical Stock - Today").toString.Trim)