Microsoft Most Valuable Professional

Chris Pietschmann

An MVP From Wisconsin



LINQ to JavaScript (JSLINQ) Open Source Project Launched!

I know LINQ is still rather fresh to everyone yet, and you may not have really used it much, but I just started a new Open Source project called "LINQ to JavaScript". Or, JSLINQ for short. This project brings the ease of querying data collections down to the JavaScript world.

Here are some simple examples of using LINQ to JavaScript:

var myList = [
{FirstName:
"Chris",LastName:"Pearson"},
{FirstName:
"Kate",LastName:"Johnson"},
{FirstName:
"Josh",LastName:"Sutherland"},
{FirstName:
"John",LastName:"Ronald"},
{FirstName:
"Steve",LastName:"Pinkerton"}
];

// Select some data by passing in the clauses as Strings
var test = From(myList).
                Where(
"item.FirstName == 'Chris'").
                OrderBy(
"item.FirstName").
                Select(
"item.FirstName");

// Select some data by passing in the clauses as Methods
var test2 = From(myList).
                Where(
function(item){return item.FirstName == 'Chris';}).
                OrderBy(
function(item){return item.FirstName}).
                Select(
function(item){return item.FirstName});

// You can also mix the two
var test3 = From(myList).
                Where(
function(item){return item.FirstName == 'Chris';}).
                OrderBy(
"item.FirstName").
                Select(
"item.FirstName");

As you can see from the above examples JSLINQ supports two methods of defining the operator clauses:

1) You can pass in a string representation of the clause that will get evaluated to return the desired data.

2) You can pass in a method that will get evaluated to return the desired data.

By supporting both of these methods we are able to support two different, easy to write, yet powerful methods of querying any data you may have within JavaScript.

Go check out LINQ to JavaScript here, and download the source!

Currently rated 5.0 by 1 people

  • Currently 5/5 Stars.
  • 1
  • 2
  • 3
  • 4
  • 5

Categories: General
Posted by crpietschmann on Thursday, January 24, 2008 3:00 PM
Permalink | Comments (0) | Post RSSRSS comment feed

Related posts

Add comment


(Will show your Gravatar icon)  

  Country flag

[b][/b] - [i][/i] - [u][/u]- [quote][/quote]



Live preview

Tuesday, January 06, 2009 7:37 PM

About the author

I'm Chris Pietschmann, go to the About Me page to learn more about me.

Search

Sponsors

Web.Maps.VE - ASP.NET AJAX Virtual Earth Mapping Server Control

Recent comments

Disclaimer


This work is licensed under a Creative Commons Attribution 3.0 United States License, unless explicitly stated otherwise within the posted content.
© Copyright 2004 - 2009 Chris Pietschmann