Closed T0BiD closed 3 years ago
Syntax like "From row In dtToFilter" is not supported -- what is possible to use you may found in the unit test: https://github.com/nreco/lambdaparser/blob/master/src/NReco.LambdaParser.Tests/LambdaParserTests.cs
In short, you may call methods or delegates, get object properties/fields, use boolean & math operators. But you cannot write cycles like for/foreach (this is by design).
Also, if "row" is not a delegate and you want to access values via indexer, valid syntax is C#-like: row["Name"]
Thanks for your quick answer
So bascially, what I have in mind is not possible, right?
It's in VB.Net, so row("Name") is valid
So bascially, what I have in mind is not possible, right?
You may iterate rows in your VB.NET code, and call "Eval" for each row (reference to the row object should be passed to the evaluation context) and in this way to implement a filter with an expression that can be defined in the run-time.
It's in VB.Net, so row("Name") is valid
LambdaParser has its own syntax, there is no any relation to language you use (doesn't matter VB.NET or C#).
Alright thanks a lot, I'll look into it further.
Oh ok.. I missed that.
Hi,
after a lot of searching I came across this package which seemed perfect for what I needed.
I'm basically trying to filter a DataTable with a LINQ query that's been generated in runtime.
Imagine I have the DataTable dtToFilter, I'd do something like this:
(From row In dtToFilter.AsEnumerable Where row("Name").ToString.StartsWith("A") OR row("Name").ToString.StartsWith("B") AND row("Age").ToString = "18" AND row("Occupation").ToString.Contains("rpa") Select row).CopyToDataTable
In my case, the above code is generated an therefore available in a string variable (
filterString
). My idea was to use your package like this:Unfortunately it throws the following error:
Do you have any tips on how to solve this or is this not possible?
Edit: Here's a simple fiddle: https://dotnetfiddle.net/uK5Mbe