Quantcast
Channel: ClearScript
Viewing all articles
Browse latest Browse all 2297

New Post: Cannot use Linq Where and Select Extension Methods

$
0
0
Hello!

ClearScript doesn't convert script functions to delegates automatically, but it provides an easy way to create a delegate that invokes a script function. Try something like this:
engine.AddHostType("Enumerable", typeof(Enumerable));
engine.AddHostType("ProjectPredicate", typeof(Func<Project, bool>));
engine.Execute(@"
    predicate = new ProjectPredicate(function (w) { return w.Id == 100; });
    result = uow.Projects.Where(predicate).ToList();
");
Please let us know if this doesn't work for you.

Thanks!

Viewing all articles
Browse latest Browse all 2297

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>