Wednesday, September 14, 2005 5:52 PM
News coming out of the PDC about an exciting new a set of standard query operators for use in working with data regardless of the data source!
In essence they are a set of .net libraries that will extend C# and Visual Basic, from the examples on Microsoft site there is a strong impression that this is a sort of SQL type addition to the languages, that still happily works in a OO fashion.
For example extracted from the Microsoft website.
This sample prints each element of an input integer array whose value is less than 5. The sample uses a query expression to create a new sequence of integers and then iterates over each element in the sequence, printing its value.
public void Linq1() {
int[] numbers = { 5, 4, 1, 3, 9, 8, 6, 7, 2, 0 };
var lowNums =
from n in numbers
where n < 5
select n;
Console.WriteLine("Numbers < 5:");
foreach (var x in lowNums) {
Console.WriteLine(x);
}
}
Result
Numbers < 5:
4
1
3
2
0
This is very exciting because it allows developers a consistency when dealing with any data-source. The hope is that the days of a different sets of code for Oracle, Sybase, SQL Server et al so we can get to a really uniform DAL (Database Access Layer) are here.
The Microsoft LINQ website can be found here.
The question I haven't quite found the answer for yet is will LINQ work on the new version of .Net Mobile?
Anyway, for now eat your heart out Java!