I am wondering if it is possible to use LINQ with NLua? I have searched various sources including the project's github page, but without any luck. I got the following minimal C# example:
using (var lua = new Lua())
{
lua.LoadCLRPackage();
lua["data"] = new[] { 1, 2, 3, 4, 5 };
var res = lua.DoFile(@"C:\..\MyLua.lua");
}
MyLua.lua
looks like this:
luanet.import_type('System.Linq')
-- syntax error near 'in'
res = from d in data where d > 2 select d
-- ')' expected near '='
res = data:Where(x => x > 2)
return res
When executed, the syntax errors (shown as comments in the lua script above) are returned by NLua. It would be nice to know if this is by design and if so, if any future version of NLua is going to support LINQ?