And Also I have another table called “cus_data” which having following column and data;
cusName | AGE
Mr. ABC | 50
Mr. DEF | 66
Mr. GHI | 74
Okay. Now I want to iterate my "cus_data " data table with age column compare with “Age_DT” data table “age_range” column and check whether if the customer age is falling to its range if so what is the rate ? . Also if cusotmer age is not in the “Age_DT” range I want to add the customer name into separate data table (what ever DT name but need to sorted the record)
Example : Match record
Mr. ABC AGE is “50” and he is covered under “Age_DT” data table 1st row which is "18-60 " age range
Hope you understand my question . And seek your support on this regard.
@Yoichi , Thanks for the solution this works perfectly fine until u provide matchable age data. Exampe if you pass some person age is not in the given range ,
Mr.JKL 17 flow get error .
Also as I mentioned in my first requirement I need to store the data which are not matching in a separate data Table.
Seek your advice and appreciate your support given
This expression create dictionary which key is cusName and value is datarow of datatable for rate. If there is no range which matches his/her age, Nothing(null) is set.
dtCus.AsEnumerable.ToDictionary is LINQ method to create dictionary
Function(r) r("cusName").ToString is set each item of cusName column as key of the dictionary. (1st argument of ToDictionary method)
Unmatched record is extracted by the following LINQ expression using the above dictionary. (filter records which doesn’t exist in keys of the dictionary)
dtCus.AsEnumerable.Where(Function(r) not dict.Keys.Contains(r("cusName").ToString)).ToArray