Comparing the start of a dataset value to a dynamic list of values

I have a dataset containing a product.
I have a list of possible values the product can start with. Values may be added and removed from the asset over time so the number of values is not fixed.
The values in de list can vary in length but the product always starts with the value.
right now I have it hard coded.

dtsOutputLocaties.Tables(0).AsEnumerable().Where(
Function(r) r(“product”).ToString().ToUpper().StartsWith(“BG DAG”) Or
r(“product”).ToString().ToUpper().StartsWith(“DA LG”) Or
r(“product”).ToString().ToUpper().StartsWith(“DA OUD”) Or
r(“product”).ToString().ToUpper().StartsWith(“DA VG”) Or
r(“product”).ToString().ToUpper().StartsWith(“DAGBESTEDING”) Or
r(“product”).ToString().ToUpper().StartsWith(“DB”) Or
r(“product”).ToString().ToUpper().StartsWith(“FZ-DB”) Or
r(“product”).ToString().ToUpper().StartsWith(“DAGBEHANDELING”)
).CopyToDataTable()

I want to put the list in an asset so i can extract it as a List<> or Array<> and am looking for a way to compare the product (starts with) to this dynamic list. Ideas are very welcome.

@Luke69

you can use like below

generally in asset you can keep only text..so assuming values in asset are comma seaprated

dtsOutputLocaties.Tables(0).AsEnumerable().Where(Function(r) AssetVariable.Split(","c).Any(function(x) r("Product").ToString.ToUpper.StartsWith(x))).CopyToDataTable

AssetVariable is the value retrieved from asset..

cheers

Hi @Luke69

Store the prefixes in an Orchestrator asset (Text or JSON) and load them into a List(Of String).
Then replace all hard-coded StartsWith checks with Any:

dtsOutputLocaties.Tables(0).AsEnumerable().
Where(Function(r)
prefixList.Any(Function(p)
r(“product”).ToString().
ToUpper().
StartsWith(p.ToUpper())
)
).CopyToDataTable()

This way you can add/remove values in the asset without changing code.

Hi @Luke69

Store the prefixes in an Asset as a newline- or comma-separated string, convert it to a List(Of String), and filter with Any, e.g.
dtsOutputLocaties.Tables(0).AsEnumerable().
Where(Function(row) startValues.
Any(Function(value) row(“product”).ToString().
ToUpper().StartsWith(value.ToUpper()))).
CopyToDataTable()

Happy Automation

Thanks, so, ‘any’ is the key word here. Bit of a newby but trying to learn. Mega help. thanks

Find some learning help here: