Showing posts with label LINQ Extensions. Show all posts
Showing posts with label LINQ Extensions. Show all posts

Thursday, January 31, 2008

SD Times' "Does .NET With LINQ Beat Java?" Article Raises More Questions Than It Answers

David Worthington's Does .NET With LINQ Beat Java? Software Development Times article of January 30, 2008 has a snappy head but the article's deck, "Framework's data query capabilities give it an edge, experts claim," appears to be disputed by at least one "expert," namely Jonathan Bruce of DataDirect Technologies (see below.)

Worthington quotes Jonathan as saying:

DataDirect’s Bruce acknowledged that from a productivity point of view, LINQ combined with its tooling gives .NET shops a productivity advantage that the Java community cannot match. He credits Microsoft’s ability to “package [productivity patterns and tooling] all up into something useful."

That said, he noted that LINQ is an unproven technology that is new to the market and said that he could not imagine anyone making corporate bets on LINQ just yet. “On the Java side, data access is rounded and stable. As a technology officer, it is an easier bet to make [on] what will reduce risks from a data perspective,” he explained. [Emphasis added.]

If Bruce "could not imagine anyone making corporate bets on LINQ just yet," why has DataDirect announced their intention to provide EntityClient-enabled ADO.NET data providers for the Entity Framework? Java's "rounded and stable" data access sounds to me like an apologia for the status quo (a.k.a. JDBC).

Apparently, Bruce isn't aware of LINQ to Objects, LINQ to XML, and the widening variety of current third-party LINQ implemetations and upcoming Microsoft versions:

Another example is XQuery, a language designed to query XML data. XQuery, he said, does a better job with data from many venues because of XML’s flexibility. By contrast, he claimed, the current implementation of LINQ is very targeted to what the developer is querying and the ability to “mash up data sources” has not been delivered yet, Bruce explained.

One of LINQ's strong points is it's "ability to 'mash up data sources'." Jon Udell's LINQ 101 post of September 28, 2005 demonstrated a three-way join between an XML data source and two CLR objects with the PDC 2005's LINQ preview. You can now join generic sequences from sets of in-memory objects (LINQ to Objects), XML documents, relational databases (LINQ to SQL and LINQ to Databases), and other domains with LINQ to SharePoint, LINQ to ActiveDirectory, LINQ to Amazon, and LINQ to Streams. If this capability for joining IEnumerable<T> sequences doesn't enable mashups, I don't know what does.

I find LINQ to XML to be a much more approachable and practical method for querying and composing XML Infosets than XQuery and/or XSLT. It's interesting that Microsoft is working on LINQ to Stored XML to supplement or replace its pre-XQuery 1.0 implementation for the SQL Server 2005+ xml data type.

Note: I have some questions about Bruce's prognostications in the "Jonathan Bruce's Data Services and LINQ Crystal Ball Appears a Bit Cloudy" topic of LINQ and Entity Framework Posts for 1/28/2008+.

Tuesday, December 04, 2007

LINQ to XSD Redux and LINQ to Stored XML Coming

LINQ to XSD was a technology spearheaded by Ralf Lämmel while he was a member of Microsoft's Data Programmability/XML Team. He released an alpha version 0.1 for the LINQ to XML CTPs and 0.2 for the Orcas Beta 1 drop. No LINQ to XSD alpha appeared for Orcas Beta 2, probably because Dr. Lämmel returned in July 2007 to Germany to assume a full professorship in the new University of Koblenz-Landau's Computer Science Department.

Updated January 14, 2007: See below.

No one at Microsoft responded to my requests for an update to LINQ to XSD's status, including my following post of November 17, 2007 to the LINQ Project General Forum:

Ralf Lämmel updated his LINQ to XSD implementation that enables strongly-typed LINQ to XML queries from the November 2006 Preview Alpha 0.1 for the May 2006 LINQ CTP to Preview Alpha 0.2 for Orcas Beta 1 on June 5, 2007. Dr. Lämmel then returned to Germany to assume a full professorship in the Department of Computer Sciences of the University of Koblenz (Germany).

There’s been no word from the XML Team that’s responsible for LINQ to XML about an update to LINQ to XSD for the final VS 2008 bits. Hopefully, this very useful LINQ implementation won’t disappear as a result of attention attrition.

Today's LINQ to XSD Story

Out of the blue on December 5, 2007 comes Microsoft's Shyam Pather with his LINQ to XML: Visual Studio 2008, Silverlight, and Beyond presentation at the XML 2007 conference in Boston. Following the usual LINQ to XML in VB 9.0 marketing hype in the abstract, Shyam says:

We will also discuss incubation efforts for a post-Visual Studio 2008 technology, LINQ to XSD, which provides .NET developers with support for typed XML programming. LINQ to XSD contributes to the LINQ project (.NET Language Integrated Query); in particular, LINQ to XSD enhances the previously mentioned LINQ to XML technology that is expected to release in Visual Studio 2008. [Emphasis added.]

You can download the PowerPoint slides for the session here.

Shyam previously participated in the Microsoft-sponsored Interop Round Table & Happy Hour – Development Discussion on Interop and XML, which started at 4:00 PM on December 4, 2007. Douglas Crockford (Yahoo!), Miguel de Icaza (Novell Inc.), Mattew Weier O’Phinney (Zend), Vijay Rajagopalan (Microsoft), and Craig Kitterman (Microsoft) also participated. Vijay's presenting Document Interop: Ecma Office Open XML and OASIS ODF, Enterprise Interop: Identity and XML, Web Interop: Ajax with XML and JSON (with Crockford and O'Phinney).

I wonder why the XML Team and others at Microsoft had nothing to say in its blog about the apparent resurrection of LINQ to XSD. Are these "incubation efforts" secret? A "breaking news" story?

Update 1/14/2007: Hartmut Wilms reviewed Shayam's XML 2007 presentation in this December 5, 2007 InfoQ article: Post-VS 2008-Technology: LINQ to XSD and LINQ to Stored XML.

Background

Ralf posted a series of four articles on typed XML programming in mid- to late-2006:

And released the LINQ to XSD Preview Alpha 0.1 version for the and a LINQ to XSD Overview whitepaper with the last post. Following are my posts after the initial Preview Alpha 0.1 version:

Update 12/5/2007: VB MVP Bill McCarthy posted an interesting suggestion in his LINQ to XSD --> VB can do better! post of December 5, 2007 regarding implementing LINQ to XSD with a schema as a dynamic interface. Ralf discussed VB 9.0 dynamic interface implementation in his Generalized vs. dynamic interfaces post of December 23, 2006:

For instance, dynamic interfaces of some form or another would allow us to carry out XML-data binding very much in the LINQ to XSD manner, but without incurring the cost of extra objects for typed views.

VB 9.0 introduced dynamic interfaces, which Erik Meijer calls "Strong Duck Typing." You'll find an example of a simple dynamic interface implementation as part 11 of the "Overview of Visual Basic 9.0" XML 2005 conference session by Erik, Amanda Silver, and Paul Vick.

Stealth Topic: LINQ Queries Against the SQL Server 2005+ XML Data Source

Missing from the abstract is the topic that many forum participants have asked about: Queries against SQL Server 2005 and later's xml datatype.

Slide 27 introduces Future Work: LINQ to Stored XML whose goal is to "provide strongly-typed LINQ experience over data in XML database columns," which requires "[m]apping from XML schema to classes" and "[q]uery translation from LINQ expressions to [a] server XQuery expression."

Slides 28, 29 and 30 use AdventureWork's Resume table as the data source to:

  • Filter and Project on XML Scalar Attributes
  • Enumerate on Collection Type

Unfortunately, there's no word on when we might expect another alpha or beta of LINQ to SQL for Visual Studio 2008 or an early preview of LINQ to Stored XML.

Friday, July 13, 2007

New LINQ with Visual Basic Articles

The VB Team has lagged the C# group in implementing LINQ-related keywords and language features throughout the VS 2008 beta process. This situation is understandable because the C# group is in charge of the core LINQ specification, so the VB compiler group can't complete their work until the C# implementation is fully baked.

The same has been true for LINQ documentation, but it's less understandable. For example, the May 2006 .NET Standard Query Operators white paper has only C# 3.0 sample code. Until Wednesday, I hadn't seen a single working example of an expression tree or custom LINQ implementation written in VB; they were all C#-based.

LINQ to WDS

The tide may be turning with Kevin Halverson's LINQ to WDS project. (WDS = Windows Desktop Search.) In How to implement IQueryable (Part 1) and How to implement IQueryable (Part 2), Kevin delves into a detailed explanation of how to create a custom LINQ implementation that lets you execute queries against the file system with WDS's OLE DB driver. WDS is part of Vista, but you can download versions for Windows XP and Windows Server 2003 here. The project translates simple LINQ Select and Where clauses into SQL statements like this:

SELECT System.ItemPathDisplay FROM SystemIndex WHERE NOT CONTAINS(System.ItemType, 'folder') AND (System.DateCreated >= 'EarliestDate' AND System.FileName LIKE 'Expression')

Kevin's Part 1 post provides a link to download the complete source code, which totals about 500 lines. The UI is a bit Spartan: A message box wrapped by a For Each loop substitutes for the usual console output.

Note: Kevin says the project requires Beta 2 because IQueryable was been refactored after Beta 1 released. However, it works for me on the Orcas June 2007 CTP.

VB Query [In]Comprehensions

Scott Wisniewski's "Basic Instincts: Query Comprehensions" column in the August 2007 issue of MSDN Magazine covers VB's query translation, lazy evaluation, the Select, SelectMany, Where and Join query operators, and expression trees in much greater depth than I've seen before (other than in Kevin's two posts).

Scott includes a sample project that instruments most of the 48 (or 50 if you count TakeWhile and SkipWhile separately) Standard Query Operators with PerfMon counters. The current version throws an error when you open the solution because of a missing unit Test.vbproj project file. You can fix that error by removing its entry from Microsoft.Linq.Instrumentation.sln.

There's a 45-KB EULA but not even a Readme file to explain how to use the WrappedEnumerable, WrappedEnumerator, and WrappedOrderedCollection classes. I couldn't find a single comment in the project. This makes the sample project incomprehensible to most LINQ neophytes.

The VB Team must have been confident that Beta 2 would be available by the magazine's posting date because Scott's project does require Beta 2. (It needs Beta 2's IOrderedSequence interface and CreateOrderedSequence method to compile; they aren't in the Orcas June 2007 CTP.)

Maybe Scott will add some documetation to his Shameless Plug (Scott Wisniewski) post.

Tuesday, March 27, 2007

Angel Saenz-Badillos on LINQ Extensions

A search on "does not contain a definition" AsEnumerable turned up a February 23, 2007 does not contain a definition for post by Angel Saenz-Badillos, a "voice from the past." During the Whidbey beta, Angelsb had been an indispensable source of information on ADO.NET esoterica, such as Multiple Active Result Sets (MARS), connection/session pooling, asynchronous command execution, transactions, and SQLCLR user-defined types.

He and Pablo Castro saved me many hours of headscratching while writing books and magazine articles before Visual Studio 2005's RTM. Angelsb's posts and responses to forum questions have always been marvels of lucidity and completeness, despite their exclusive use of C#.

During his year or more of what I call exile in the Lotusland of JDBC, I had turned off Angelsb's RSS feed. Now I find he's working on LINQ extensions, specifically LINQ to DataSet and LINQ to Entities.

His February 23 post explains how to overcome in LINQ to DataSet code the

'System.Data.DataTable' does not contain a definition for 'AsEnumerable' and no extension method 'AsEnumerable' accepting a first argument of type 'System.Data.DataTable' could be found (are you missing a using directive or an assembly reference?)

and

The type arguments for method 'System.Linq.Enumerable.AsEnumerable<TSource>(System.Collections.Generic.IEnumerable<TSource>)' cannot be inferred from the usage. Try specifying the type arguments explicitly

exceptions by adding using/Imports System.Linq to your class and a reference to System.Data.Entity.dll to your project.

I'm looking forward to las joyas de Saenz-Badillos and, needless to say, have added his feed to my growing list of LINQ-related blogs. Recepción a bordo.

P.S.: Apparently, Julie Lerman was having the same problem as I. Her March 5, 2007 LINQ and Entity Framework Resources for March Orcas CTP post was the second hit of my search.