LHS: Result | datatype: List(Of Datarow)
(From s in searchtermlistvar
From r in yourdatatablevar.AsEnumerable
then based on the filter result we can copy it to a datatable or clone the origin one
check within an if acitvity
Result.Count > 0
Then: dtResult = Result.CopyToDataTable
Else: dtResult = yourdatatablevar.Clone
Keep in mind that maybe the LINQ requires a rework. Will check it and if needed will answer it on next post
So you was forced to loop over the Keywords
Also you was not running over the given Set.
With modified keywords: A, Apple
| Angora| 2|
Your contains approach would fail. When Datacolumn values are to trim (see above) a change to equal (=) also would fail.
It is not about that it is not possible to get involved a filter datatable into an implementation. But if it results into more items to model, then it is also valid to solve it more compact.
But we do also have other implementation options. Another one is using the select method and using the Operator IN
So why not having the choice and selecting the approach which is individually preferred. I dont see a reason why Filter datatable is a must to use it. Also when it has some weakness e.g. the case from above where a trim is needed
" I dont see a reason why Filter datatable is a must to use it. "
It’s not a must. I’m simply dispelling (again) the myth that it should be avoided to save time. The benefit is that it’s easier to understand for those who may come after you and have to maintain your code. It makes it easier to visualize what is happening.
run it show us the dump.
Contains will catch also Angora as it is matching on A, But Angora is not within the Keyword list
Again: I am not talking about timings
However, this side discussion can be closed as it is not adding new insights and as long not a running proof is shared the argumentation for the filter data activity looks questionable related to the case
keywords: A, Apple
| Angora| 2|
not catching A (when =) and matching Angora (when contains)
Well yeah, that’s how contains works. If you’re looking for A you do contains(“A”) and if you’re looking for “Angora” you do contains(“Angora”) - it’s not the spaces causing the issue, it’s not using the correct search term.
" Again: I am not talking about timings"
The OP is.
Your “A, Apple” point is silly. All you’re doing is changing what you want to look for.