I'm using VB in a project, together with EF.PLUS https://entityframework-plus.net/
I want to use FirstOrDefaultDynamic
, but I didn't found any example for usage in VB - all examples are in C#.
Specifically I have an array of array of strings, and I want to find an element in it:
dim a = {
{"a", "a1"},
{"b", "b1"},
{"c", "c1"}
}
dim elem = a.FirstOrDefaultDynamic("x(0) = y", new with {y="a"})
But I get error on evaluating the expression.
FirstOrDefaultDynamic
accepts only string expression as parameter, not predicate (function).
The C# example is
var list = ctx.WhereDynamic(x => "x > 2").ToList();
but it still accepts a function returning an string expression which is to be evaluated.
Any idea on the VB syntax?
CodePudding user response:
Disclaimer: I'm the owner of the project Entity Framework Plus
Only the C# syntax is supported.
So if you want to use any Dynamic
method such as FirstOrDefaultDynamic
from this library, you will need to stick with the C# syntax.
There is no plan to support VB
syntax.
CodePudding user response:
Just to clarify the answer from Jonathan Magnan :
The expression string used as parameter should use C# syntax, even if the call is made from VB.
Usage example:
Dim elem = a.FirstOrDefaultDynamic("x => x[0]=y", New With {.y = "MyTestVal"})