[]CSE & LINQ: What am I missing?

General discussions related to using the C# Script Engine in APL+Win.

Moderators: Tech Support, phpbb_admin

[]CSE & LINQ: What am I missing?

Postby Ajay Askoolum » October 14th, 2016, 4:25 pm

The code:
Code: Select all
    ∇ APLLINQ
[1]   ⍝ Ajay Askoolum
[2]   ⎕cself←'c1' ⎕cse 'Init' 'System'
[3]   ⎕cse 'returnonerror' 1
[4]   ⎕cse 'LoadAssembly' 'C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\.NETFramework\v4.6\System.Core.dll'
[5]   ⎕cse 'LoadAssembly' 'C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\.NETFramework\v4.6\System.Data.Linq.dll'
[6]   ⎕cse 'LoadAssembly' 'C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\.NETFramework\v4.6\System.Data.DataSetExtensions.dll'
[7]   ⎕cse 'ExecStmt' 'using System;using System.Collections.Generic;using System.Linq;'
[8]   ⎕cse 'ExecStmt' 'IEnumerable<int> aa = Enumerable.Range(1, 10).Select(x => x * x);'
[9]   ⍝⎕cse 'ExecStmt' 'object[] qq = Enumerable.Range(1, 10).Select(x => x * x);'
    ∇
The session:
Code: Select all
      APLLINQ
0
Name=System.Core, Version=4.0.0.0, Culture=, PublicKey token=B7-7A-5C-56-19-34-E0-89
Name=System.Data.Linq, Version=4.0.0.0, Culture=, PublicKey token=B7-7A-5C-56-19-34-E0-89
Name=System.Data.DataSetExtensions, Version=4.0.0.0, Culture=, PublicKey token=B7-7A-5C-56-19-34-E0-89
0
0
      ⎕cse 'GetValue' 'aa'
CSE ERROR: FATAL ERROR. Method: GetValue - Message: Type 'System.Linq.Enumerable+WhereSelectEnumerableIterator`2[[System.Int32, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089],[System.Int32, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089]]' in Assembly 'System.Core, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089' is not marked as serializable.

The code runs but I am unable to retrieve the value.
(I get a similar error when retrieving the variable defined in the line that is commented out ... after executing it.)
Ajay Askoolum
 
Posts: 884
Joined: February 22nd, 2007, 2:16 am
Location: United Kingdom

Re: []CSE & LINQ: What am I missing?

Postby Ajay Askoolum » October 14th, 2016, 5:08 pm

I solved the problem by changing line[8] to
Code: Select all
[8]   ⎕cse 'GetValue'  ' Enumerable.Range(1, 10).Select(x => x * x).ToArray();'
Ajay Askoolum
 
Posts: 884
Joined: February 22nd, 2007, 2:16 am
Location: United Kingdom


Return to APL+Win & The C# Script Engine

Who is online

Users browsing this forum: No registered users and 11 guests

cron