How to use linq.js with sharpkit

309 views
Skip to first unread message

Ramin Zarei

unread,
Aug 16, 2012, 5:49:50 AM8/16/12
to shar...@googlegroups.com
Hi.

How to use  linq.js javascript library?
Can any one provide Extension for linq.js javascript library?

Thanks.


Dan-el Khen

unread,
Aug 16, 2012, 10:53:31 AM8/16/12
to shar...@googlegroups.com
This library support has not started yet, if you'd like I can open a new project in SVN for this library and give you write access to it, I will also be able to help you out if you have any issues. If not, feel free to post an 'enhancement' request in our issues list:

You can star the issue and get notified when it's implemented.

Cheers
Dan-el

Arithmomaniac

unread,
Aug 16, 2012, 12:17:46 PM8/16/12
to shar...@googlegroups.com
Have you already tried the LINQ support inside CLR mode? It's not perfect, but may be sufficient.
As Dan-el noted, you can also roll your own (instructions at http://sharpkit.net/Wiki/Using_Web_Libraries.wiki ).

Ramin Zarei

unread,
Aug 16, 2012, 12:50:29 PM8/16/12
to shar...@googlegroups.com
Would you please provide me a sample with CLR mode linq, does it has groupby and where methods?

Ramin Zarei

unread,
Aug 16, 2012, 12:54:51 PM8/16/12
to shar...@googlegroups.com
Hi,
At the moment i'm very busy, however later i'll contact u.

Thanks. 

Arithmomaniac

unread,
Aug 16, 2012, 2:33:36 PM8/16/12
to shar...@googlegroups.com
Where, yes.
GroupBy, no.

Ramin Zarei

unread,
Aug 16, 2012, 2:44:57 PM8/16/12
to shar...@googlegroups.com
Thanks.

Dan-el Khen

unread,
Aug 18, 2012, 4:33:40 AM8/18/12
to shar...@googlegroups.com
Thanks Arithmomaniac!

In any case I have started a project in SVN to support linq.js:

Cheers
Dan-el

Mohammad Nikravan

unread,
Oct 29, 2012, 6:11:14 AM10/29/12
to shar...@googlegroups.com
Hi, its my questions too.
Is it still under development?
I didn't understand how to use linqJS. I don't want use CLR mode too.
Regards

Dan-el Khen

unread,
Oct 30, 2012, 10:58:51 AM10/30/12
to shar...@googlegroups.com
This library is already finished, I have added a few fixes right now, and a sample project, but it seems fine:

            var x = Enumerable.From(new JsArray<JsString>{"asdsad", "ASdsad"}).Where(t=>t.substr(0, 1)=="a").ToArray();


Dan-el

Mohammad Nikravan

unread,
Oct 30, 2012, 11:16:28 AM10/30/12
to shar...@googlegroups.com
Didn't you have plan to add language extension for it?
Regards

Dan-el Khen

unread,
Oct 30, 2012, 11:22:30 AM10/30/12
to shar...@googlegroups.com
I'm not sure what you mean by language extension - but this library seem to work perfectly, so I'm not sure what is the need. Did you have anything specific in mind?

Dan-el

Mohammad Nikravan

unread,
Oct 30, 2012, 11:39:17 AM10/30/12
to shar...@googlegroups.com
I mean same as System.Linq. Add extension to JavaScript collection objects such as JsArray and JsObject
sample:
var s = new JsArray();
s.<show linq methods here>
Regards

Dan-el Khen

unread,
Oct 30, 2012, 11:40:36 AM10/30/12
to shar...@googlegroups.com
Yes, it's possible to add something like this:

var x = new JsArray();
x.AsLinqJsEnumerable().Where(...)

Would you like me to add this helper extension method?

Dan-el

Mohammad Nikravan

unread,
Oct 30, 2012, 12:09:13 PM10/30/12
to shar...@googlegroups.com
Would you like me to add this helper extension method?
Thanks you that ask from me, I think you are more expert to decide, but Why .AsLinqJsEnumerable?
C# automatically add Linq extension when the "using System.Linq" added to header.
Isn't possible to do same as C# so the method show on Collection without AsLinqJsEnumerable?
By the way I am not Linq veteran.
Regards

Dan-el Khen

unread,
Oct 30, 2012, 12:14:28 PM10/30/12
to shar...@googlegroups.com
The AsLinqJsEnumerable() method replaces the Enumerable.From() method, you have to call it, it's not an invisible method, I have simply provided a different calling style to the same function using extension methods. I have put this method under SharpKit.JavaScript namespace, so you won't have to add any other usings, only to reference LinqJs assembly.

Does that make sense to you?

Dan-el

Mohammad Nikravan

unread,
Oct 30, 2012, 4:23:24 PM10/30/12
to shar...@googlegroups.com
Looks good, maybe AsLingJs is enough.
Regards

Dan-el Khen

unread,
Oct 31, 2012, 3:41:50 AM10/31/12
to shar...@googlegroups.com
I have added: ToLinqJsEnumerable() - When I thought about it 'As' is not a good prefix for the method, since it's a real method invocation, and not some invisible casting. In any case, it shouldn't be so bad that it's a bit of a long method name - since Visual Studio already autocompletes the code anyway... :-)

Dan-el

Mohammad Nikravan

unread,
Oct 31, 2012, 4:16:24 AM10/31/12
to shar...@googlegroups.com
But I didn't understand why ToLinqJsEnumerable() is necessary while C# does need such method for System.Linq
Regards

Dan-el Khen

unread,
Nov 1, 2012, 3:53:17 AM11/1/12
to shar...@googlegroups.com
C# might not need this method, but LinqJs does require it. You can create a shortcut method to do it automatically if you want, but you should be aware that Enumerable.from() method must be invoked - either statically, or automatically, in order to convert your JsArray into a LinqJs compliant enumerable.

zare...@gmail.com

unread,
Aug 27, 2016, 10:37:43 PM8/27/16
to SharpKit Support


در پنجشنبه 16 اوت 2012، ساعت 14:19:50 (UTC+4:30)، Ramin Zarei نوشته:
Reply all
Reply to author
Forward
0 new messages