Tuesday, December 18, 2007

LINQ and Entity Framework Posts for 12/17/2007+

Note: This post is updated daily or more often, depending on availability of articles.

Mike Taulty Tackles Substituting LINQ to SQL for The Entity Framework and Data Updates

Continuing where he left off in his ADO.NET Data Services - Getting Started (2) post of December 19, 2007 (see below), ADO.NET Data Services - Using LINQ to SQL rather than LINQ to Entities later that day follows Guy Burstein's ADO.Net Data Services Part 1 - Building a Simple Web Data Service tutorial to substitute LINQ to SQL for the Entity Framework and LINQ to Entities as the data source.

For updates, the data source must also support IUpdatable as well as IQueryable. Tech lead Pablo Castro says in the "What's Missing" section of his Astoria data sources and system layering post of September 27, 2007:

Update: [W]hile this model enables us to support querying over arbitrary .NET classes that expose containers of instances as IQueryable objects, it does not say how to update stuff. Discussing the update model will take a whole post (or several, most likely), but the short story is that we’ll define an interface, something like IUpdatable or whatever names works, that has the basic operations we need to perform in order to handle updates. The interface would have primitive operations for adding a new resource, remove an existing resource, applying modifications to resources and also handle linking/unlinking of resources.

Mike went on to extend his DataContext's partial class with insert and delete operations, but finds there's no way to provide "original values" as noted in the following of one hour earlier.

Added: 12/19/2007

Mike Tautly Tracks HTTP Traffic Between .NET Data Services and Clients

Mike uses Northwind as an example with the Entity Framework as the data source in ADO.NET Data Services - Experimenting with .NET Client Access Whilst Sniffing the HTTP Traffic of December 19, 2007 while he experiments with the LINQ to REST syntax for inserts, updates, and deletes. He can't find the magic commands to implement cascading deletions for a Customer and all its associated Orders objects.

Added: 12/19/2007

Book Review: LINQ Quickly (Packt Publishing)

Michael Schwartz reviews LINQ Quickly by N. Satheesh Kumar, a 250-page "linq quick-starter" book (as the URL states), in his LINQ Quickly (Book Review) post of December 19, 2007. The US$34.99 list price seems a bit high for this thin a title.

The author and/or advertising copy writer seems to have their .NET version a release behind in these blurb sections:

This book gets you started with LINQ and shows how it will make your programming life easier by making use of new features from the .NET Framework 3.0. This book is split into seven chapters, each of which is dedicated to presenting a feature of LINQ and its usage in real-life scenarios. ...

Overview of new features for LINQ in .NET 3.0—partial methods, expressions, anonymous types, initializers, and implicitly typed local variables. [Emphasis added.]

The following implies that LINQ's "filtering, ordering, and grouping capabilities" are weak:

Directly querying the collections and filtering the required values without using powerful filtering, ordering, and grouping capabilities. [Emphasis added.]

Not very promising.

Added: 12/19/2007

Daniel Cazzulino and Juan Wajnerman Create LINQ to Mock (Objects)

Dan's Linq to Mock: Moq is born and Juan's Mocking with LINQ: Moq is here! posts of December 19, 2007 describe the initial release of LINQ to Mock (Moq). According to the Moq (pronounced Mock-Q) home page on Google Code:

Moq (pronounced "Mock-you") is the only mocking library for .NET developed from scratch to take full advantage of .NET 3.5 (i.e. Linq expression trees) and C# 3.0 features (i.e. lambda expressions) that make it the most productive, simple and refactoring-friendly mocking library available.

The Moq wiki's QuickStart includes several syntax examples. Looks like an interesting mocking method for .NET C# 3.5 projects in general, not just projects that use LINQ.

Added: 12/19/2007

Mike Taulty Continues His ADO.NET Data Services Tutorial

In his ADO.NET Data Services - Getting Started (2) post of December 19, 2007, Mike explores the classes of Microsoft.Web.Data.dll, including WebDataService<T>, IWebDataService, and IWebDataServiceProvider.

Mike observes:

It's been said that you can use "any old IQueryable" in the latest preview of "Data Services" rather than having to use Entity Framework and (from experimenting with LINQ to SQL) that looks to be true but IQueryable doesn't deal with the business of inserts/updates/deletes and so if you want your "Data Services" data to do more than just Query then your T needs to implement IUpdateable which LINQ to SQL doesn't (more on that in a later post).

Another interesting point is that Astoria uses the Entity Framework's Storage Schema Description Languages (SSDL) file to supply the metadata for the Astoria client API, as Christian Weyer observed in his ADO.NET Data Services ("Astoria") Service Metadata post of December 12, 2007. The .ssdl file is used regardless of the services data source type.

Mike's initial ADO.NET Data Services - Getting Started post of the same date consists of a pointer to the Creating ADO.NET Data Services docs.

Added: 12/19/2007

Eric White Explores LINQ to XML for Processing SpreadsheetML

Eric continues his "LINQ to OOXML" series with Using LINQ to XML to process Open XML: The SpreadsheetML Class of December 19, 2007. Following is a partial description of the three members of the LtxOpenXml namespace:

  • The SpreadsheetML class [which derives from the OpenXmlDocument class] contains three nested classes, Sheet, Row, and Cell, which represent some convenient abstractions for a SpreadsheetML document. These nested classes are written in the spirit of dynamic types, with the most terse syntax possible. We don't care that all properties are read/write; all of this code is written in a functional style, where no variables are mutated.
  • The SpreadsheetML class contains the Sheets method, which iterates through the sheets in the workbook.
  • Each Sheet contains a Rows method, which iterates through the rows in the sheet.
  • Each Row contains a Cells method, which iterates through the cells in the row.

His post includes a link to Example that uses the OpenXmlDocument, WordprocessingML, and SpreadsheetML Classes (December 19, 2007) for the Sheet, Row, and Cell members.

Added: 12/19/2007

Julie Lerman Shows You How to Process "Miscellaneous" Stored Procedures with the EDM Designer

Her Implement SELECT Stored Procedures that return miscellaneous data in CTP2 of EF Designer post of December 18, 2007 provides step-by-step, illustrated instructions for processing a stored procedure that returns a rowset that isn't included in the project's schemas. The process requires manually editing the .ssdl, .msl, and .csdl files.

Added: 12/19/2007

Doug Rothaus Calculates Standard Deviation with LINQ and VB 9.0

The VB Team's LINQ Cookbook, Recipe 12: Calculate the Standard Deviation (Doug Rothaus) of December 18, 2007 shows you how to write extension methods to calculate StDev (standard deviation) and StDevP (standard deviation for the entire population). You can use the extension methods in the Into clause of an Aggregate, Group By or Group Join expression.

Added: 12/19/2007

Jonathan Carter Starts 11-Part ADO.NET Data Services Series

Jon has reached the Sixth Episode in his ADO.NET Data Services Training Series that began on December 12, 2007. Jon's a Microsoft evangelist for the .NET Framework and Visual Studio. In an earlier avatar, he was a writer for numerous magazines, so his episodes are more like stories than tutorials. The protagonist is ...

Phillip, who runs a cell phone resale company, and is looking to ramp up his business. Phillip has an extensive database of cell phones, carriers, and manufacturers. Lots of time and effort has been put into the population and maintenance of his precious data. One day he realizes that all that time he put into his database should be making him more money, so he decides to provide access to his data store to other companies looking to build a web presence but don’t have the resources Phillip has.

Here are the "chapters," with links to those complete as of the latest update:

  • ADO.NET Data Services Part 1: Services (December 12, 2007)
  • ADO.NET Data Services Part 1: Services (contd.) (December 12, 2007)
  • ADO.NET Data Services Part 2: Service Addressing (December 13, 2007)
  • ADO.NET Data Services Part 3: Query Parameters (December 14, 2007)
  • ADO.NET Data Services Part 4: Clients (December 15, 2007)
  • ADO.NET Data Services Part 5: LINQ (December 17, 2007)
  • ADO.NET Data Services Part 6: AJAX (December 19, 2007)
  • ADO.NET Data Services Part 7: Data Modification- Client (December 30, 2007)
  • ADO.NET Data Services Part 8: Service Operations
  • ADO.NET Data Services Part 9: Interceptors
  • ADO.NET Data Services Part 10: Open Objects
  • ADO.NET Data Services Part 11: Service Hosting

    Thanks to Andy Conrad for the heads-up.

    Added: 12/19/2007 Updated: 1/1/2008

    Bill Horst Translates SQL GROUP BY and HAVING Clauses to LINQ Expressions

    Bill's Converting SQL to LINQ, Part 5: GROUP BY and HAVING (Bill Horst) of December 18, 2007 continues the series that shows you how SQL statements translate to the VB 9.0 version of LINQ expressions.

    Added: 12/19/2007

    David Sceppa: Updated ADO.NET Entity Framework Sample for Beta 3

    David's Sample ADO.NET Entity Framework Provider - Beta 3 describes the new sample provider code that's been updated for Entity Framework (EF) Beta 3. The new release, which you can download here, has changes to the provider manifest, includes the manifest specification, and adds VS 2008's Data Designer Extensibility (DDEX) features to enable third-party providers to integrate with the EDM Designer.

    Still No Word about the Status of Oracle's ADO.NET Entity Framework Provider

    Another David Sceppa December 18, 2007 post, The Entity Framework - Not Just For SQL Server!, indicates that the Entity Framework (EF) isn't for Oracle. The list of providers is the same as that of the earlier EF Beta 3 press release discussed in my Entity Framework Beta 3 Available for Download post of December 6, 2007; Oracle is still among the missing.

    Update to ADO.NET Data Services Online for CTP1 in Limbo, POX Scheduled for V1

    According to a reply by Mike Lasko to my Astoria Forum question regarding when the Online Services at http://astoria.mslivelabs.com/OnlineService.aspx would be updated to CTP1 and if Plain Old XML support was in the works for ADO.NET Data Services:

    We don't have a timeline yet to update the online service to CTP1.  Once we do, we'll post to blogs.msdn.com/astoriateam

    Regarding POX ... We are strongly looking at adding this serialization into the production version.  We'll likely get this in for V1.

    Good news on the POX front, but Online Services for developers are useless until updated to CTP1.

    Guy Burstein: Using Stored Procedures with Entity Framework Beta 3

    Guy's ADO.Net Entity Framework Tools: Stored Procedures post of December 17, 2007 shows you how to map stored procedures to Entity Data Model Insert, Update, and Delete operations as well as to a Function Import operation to populate entities. The tutorial includes screen captures of all critical steps.

    Guy Burstein: Service Operations with WebGet for ADO.NET Data Services

    Guy continues his ADO.NET Data Services (Astoria) series with the ADO.Net Data Services Part 2 - Using Service Operations with WebGet post of December 16, 2007 which uses a Table Valued Function with LINQ to SQL as a Service Operation. Guy shows you the URL required to call a service operation by its name followed by parameters, as in http://localhost:2445/BlogData.svc/PostsByCategory?categoryID=2, where PostsByCategory is the service name.

    Guy Burstein Test Drives Zlatko Michailov's eSqlBlast Tool

    His ADO.Net Entity Framework: eSqlBlast Tool for E-SQL Queries post of December 13, 2007 provides an illustrated introduction to using Zlatko Michailov's eSqlBlast Tool, which lets you run queries against entities defined by a selected .ssdl, .msl, and .csdl schema file set in a Windows UI.

    Julie Lerman also is an eSqlBlast fan. She considers eSqlBlast the Entity Data Model's Query Builder.

  • 2 comments:

    Oleg Yaroshevych said...

    It is a bit confusing to read that EF isn't for Oracle. For Oracle corp. - is's correct (as yet), but nof for Oracle Server. There is a 3rd party EF provider for Oracle Server from Core Lab, as stated in the David Sceppa blog.

    We at Core Lab are currently working on supporting EF Beta3 for all our ADO.NET providers, so look forward for news from us.

    Best regards and happy coding, Oleg.

    Roger Jennings (--rj) said...

    Hi, oleg,

    My item related to Oracle Corp., who previously announced that an EF provider was in progress.

    I mentioned your Oracle driver in the linked post.

    Cheers,

    --rj