Tuesday, October 30, 2007

LINQ and Entity Framework Posts for 10/29/2007+

More Tidbits from Julie Lerman: An Upgrade to the EDM Designer and QueryViews vs. Defining Views

Julie's Another tidbit from the forums.. what's coming in the EDM Designer post of November 2, 2007 quotes the ADO.NET Team's Noam Ben Ami:

We are hard at work on this feature right now and hopefully we'll be able to get it into CTP2 of the designer.

Along with support for stored procedures, it is our highest priority.

and offers three prognostication of things to come for the EDM Designer.

EDM QueryViews vs Defining Queries (and read-only views) of the same date explains in great detail the difference between a QueryView that you specify in the mapping layer (MSDL) and a Defining Query for which you write the T-SQL in the physical layer (SSDL).

Added: November 3, 2007

A QueryDataSource Replacement for the LinqDataSource

Bernal Schooley's LINQ : Paging and sorting LINQ Queries with a custom QueryDataSource post of November 3, 2007 describes the LinqDataSource as "the Linq equivalent of the SqlDataSource, something many people avoid at all costs." His custom QueryDataSource server control handles server-based paging and sorting for ordinary LINQ queries and, unlike the LinqDataSource, isn't connected at the hip to LINQ to SQL.

Bernal has a brief but interesting series of posts on LINQ to SQL starting in late September 2007.

Added: November 3, 2007

Julie Lerman: Handling DB Schema Changes with the Entity Data Model Designer

One of the primary selling points of the Entity Framework (EF) and its Entity Data Model (EDM) is the ability to deal with minor changes to the underlying database's schema with edits to the XML files for the physical (SSDL) and mapping (MSDL) layers. You don't need to alter source code and recompile your data layer.

Julie's Entity Data Model - What to do when a change is made in the database of November 2, 2007 demonstrates how to edit the SSDL and MSDL files with the Beta 2 version of the EDM Designer. In this case the changes are to the names of two columns. Things get a bit trickier when DBAs make structural changes to the schema, such as splitting or consolidating tables.

Added: November 2, 2007

Beth Massi Posts Four New LINQ to XML Video Segments

Beth's New Visual Basic LINQ to XML Videos Released! post of November 2, 2007 describes four new video clips that "walk you through the basics of LINQ to XML, creating, querying and transforming documents as well as how to import XML namespaces and infer schemas to enable IntelliSense." The last video covers the LINQ to XML application described in the "Beth Massi Moves Excel Data to and from SSCE with LINQ to XML" topic below.

Beth's post also includes an updated set of links to her previous LINQ to XML articles.

Added: November 2, 2007

Multi-Tier Improvements Coming to Entity Framework

Julie Lerman reports in her A hint of what to look for in Entity Framework Beta3 post of November 1, 2007 that the ADO.NET team intends to make the EntityKey for 1:m associations (EntityRefs) serializable for WCF messaging. 

I assume in my Multi-Tier Improvements Coming to Entity Framework post of November 1, 2007 that the DataContractSerializer serializes both EntitySet(s) and EntityKey(s), but it's not entirely clear from Brian's statement that Julie quotes.

Added: November 1, 2007

Zlatko Michailov's Entity SQL Tip #1: No JOINs

Entity SQL Tip #1: A well defined query against a well defined entity data model does not need JOIN.

Navigation properties in combination with nesting sub-queries should be used instead. These latter constructs represent task requirements much more closely than JOIN does. That makes it easier to build and maintain correct Entity SQL queries.

Added: November 1, 2007

Julie Lerman Demystifies Creating Associations in the EDM Designer

If you don't have a predefined primary key:foreign key relationship predefined for a pair of related tables your mapping with the Entity Framework's Entity Data Model (EDM) designer, establishing the relationship with the designer is a painful process to some and a complete mystery to most folks. For this reason, Entity Framework pilgrims usually set up the relationships for all their tables' foreign keys in the SQL Server Management Studio [Express] Foreign Key Relationships dialog before starting the mapping process. If you're working with a database that's not under your control, you probably don't have the ALTER TABLE privileges necessary to add foreign key constraints and enforce referential integrity.

Julie comes to the rescue with another lavishly illustrated set of step-by-step instructions in her October 31, 2007 Mapping Associations in the EDM Designer post. Her tutorial for establishing a one-to-many relationship between two tables in the EDM designer keeps you out of the sand traps and away from the water hazards that the ADO.NET folks appear to have added just to make the process of setting navigation properties "interesting." Thanks, Julie.

Added: November 1, 2007

All's Quiet on the Project Jasper Front

Project Jasper was one of the ADO.NET team's next big things at the MIX 07 conference. There now seems to be a serious question about a Project Jasper CTP for Visual Studio 2008 RTM. Read more in my Has Project Jasper Been Swallowed by a Black Hole? post.

Added: November 1, 2007

Update 11/2/2007: Andrew Conrad left a detailed comment about the current status and future of Project Jasper. Andy notes in the comment that he's the Dev Lead for Astoria and still the Dev Lead for Project Jasper and LINQ to DataSet.

Beth Massi Moves Excel Data to and from SSCE with LINQ to XML

Most folks use Microsoft Access to import Excel workbooks into .mdb/.accdb files or SQL Server tables and Excel itself to import data from Access tables. But Beth picked SQL Server Compact Edition (SSCE) v.3.5, which has managed (System.Data.SqlServerCe) and OLE DB (Sqlceoledb35.dll) drivers but doesn't have the old-timey ODBC driver that Access requires.

So Beth's Quickly Import and Export Excel Data with LINQ to XML of October 31, 2007 post starts by copying the XML document for a dummy row from an Excel 2003 XML file and pasting it to VB 9.0's text editor (preceded by Dim sheet = ) and adding five Imports statements for the namespaces. She then replaces the dummy data with embedded expressions, and adds a query expression to import Northwind Customers data from an SSCE database into a new document and save it as Customers.xml. Finally, Beth demonstrates how to export data from Customers.xml back into the SSCE table.

I'm not so sure about the "Quickly" adverb, but it's an interesting example of LINQ to XML's capabilities and shows you why Silverlight ultimately will include LINQ to XML.

Note: Beth's smashed finger must be healing because this post is longer than some of mine.

Added: October 31, 2007

Rick Strahl's and My Issues with WCF WSDLs and LINQ

Rick Strahl observes in his WCF and segmented WSDL Files = Problems post of October 30, 2007 that the Web Service Definition Language (WSDL) documents generated by Windows Communication Foundation (WCF) Web services include a <wsdl:import namespace="someNamespace" location="uRLforWSDL"> element, which limits interoperability with more mature Web service clients. 

Apparently, Rick and I are working on similar WCF serialization techniques for LINQ to SQL entities. My Serializing Cyclic LINQ to SQL References with WCF of October 30, 2007 describes additional problems with serializing cyclic references with WCF's DataContractSerializer and the lack of standards for bidirectional serialization with id and idref attributes.

Added: October 30, 2007

Frans Bouma and LINQ to LLBLGen Pro: Part 8

It appears to me that Frans is making good progress in "trimming his expression tree" with reduction code. As Frans notes, his "current code can recognize predicates, field expressions, joins (not group joins yet), can evaluate local variables into values used into predicates, projections of single fields and entity projections" from his sample query:

string city = "Munchen";
var q = from c in metaData.Customer
        join o in metaData.Order
           on c.CustomerId equals o.CustomerId
        join od in metaData.OrderDetail
           on o.OrderId equals od.OrderId
        where c.City == city && c.Country == "Germany"
           && o.EmployeeId == 2 && (od.Quantity * od.UnitPrice) > 500
        select (o.EmployeeId > 10);

Frans provides screen captures of his custom Expression Tree Visualizer during the seven states from State 0 - Start to State 6 - The final tree has been reduced by combining select expressions.

Added: October 30, 2007

Julie Lerman Discovers Silverlight 1.1 Doesn't Support LINQ to XML or WCF (Yet)

Julie's Silverlight 1.1 - Look before you leap (into LINQ or into WCF) post of October 30, 2007 laments not researching the status of LINQ to XML and WCF in the current bits before .

I made the following comment in the "Julie Lerman to Present Sessions on Astoria at REMIX Boston and New England Code Camp" topic of my LINQ and Entity Framework Posts for 10/29/2007+ post:

Her resultsets are formatted as plain-old-XML (POX), which will be replaced by Microsoft's new Web3S XML format in a later CTP. Silverlight 1.1 has an Astoria client library; XML-formatted data is one reason that a future Silverlight version will include LINQ to XML. (Emphasis added.)

I quoted more about future Silverlight support for LINQ in the "Scott Guthrie on Using C#'s (New?) null Coalescing (??) Operator with LINQ to XML" topic in my LINQ and Entity Framework Posts for 9/14/2007+ post:

Tim Anderson posted on 9/19/2007 an interview with Scott, Scott Guthrie on .NET futures, conducted at the MIX07 UK conference held in London on September 11-12, 2007. Tim's September 11, 2007 Silverlight at Mix07 UK post mentions in his "Web service support and LINQ" section:

"Silverlight will support JSON, WCF and SOAP. It will also include LINQ, with the possibility of creating custom LINQ data providers - Guthrie mentioned possibilities like a LINQ provider for Amazon’s S3 service."

And here's an early reference from my MIX07 Session Videos with LINQ, EF, or VB[x] Hooks - Part 2 post of May 3, 2007:

Aaron and Tim have created Socializer, a Silverlight UI that demonstrates:

  • The Silverlight 1.1 Alpha client
  • LINQ to Objects in Silverlight 1.1
  • LINQ to XML in future Silverlight CTPs [emphasis added]
  • Semantic Web
  • Data binding, querying, and aggregation
  • A socially-aware rich Internet application (RIA) that includes personal content aggregated from MySpace, de.licio.us, and Flickr.

I didn't get around to researching WCF support in Silverlight 1.1, but Julie found a couple of workarounds for using WCF with the current bits.

Added: October 30, 2007

LINQ to SharePoint with Bart de Smet Webcast on October 31

LINQ to SharePoint developer Bart de Smet will join Glen Gordon and Lynn Langit for a geekSpeak Webcast at Noon PDT on Wednesday, October 31, 2007. Here's Bart's bio from the geekSpeak blog:

A former Visual C# MVP, Bart De Smet now works at Microsoft Corporation on the WPF dev team in an SDE role. Prior to this new challenge, Bart was active in the Belgian community evangelizing various Microsoft technologies, most of the time focusing on CLR, language innovation and frameworks. In his evangelism role, he's been speaking at various events and attended several international conferences including TechEd Europe, IT Forum and the PDC. In 2005, Bart graduated as a Master of Informatics from Ghent University, Belgium. Two years later, Bart became a Master of Computer Science Software Engineering from the same university.

Register for the Webcast here.

Added: October 30, 2007

Followup Resources for geekSpeak: LINQ to SharePoint with Bart De Smet with a Channel9 link to the clip.

Updated: November 3, 2007

New LINQ to Flickr Provider on Codeplex

MehfuzH has posted a new LINQ to Flicker provider on CodePex.

His New LINQ provider for Flickr post provides detailed instructions for using the API to select, add, or remove images.

Added: October 30, 2007