Linq over datatable using sample dynamic library?

I am looking for a sample linq code snippet that uses System.Linq.Dynamic versus datatable.

Dim entities = (From ent In dt.AsEnumerable().Where(String.Format("IsUSFederal == {0}", "true")) _
Select Description = ent("Description"), Acronym = ent("Acronym")).ToList

I get an error: "Not available. Where can I call these arguments." I included the DynamicLinq.vb file and the application compiles fine (except for this error). I have enabled Imports System.Linq.Dynamic, but it does not seem to work.

Any ideas? THX

+3
source share
1 answer

Enumerable.Wheretakes an argument Func(Of TSource, Boolean)as an argument and passes String.

(update)

Could not catch part of the dynamic library ... sorry. I think you need to do this:

dt.AsQueryable() 

Because extension methods in the library are defined as:

<Extension()> _
Public Function Where(ByVal source As IQueryable, ByVal predicate As String, 
                      ByVal ParamArray values() As Object) As IQueryable
+2
source

Source: https://habr.com/ru/post/1721807/


All Articles