Mike Taulty's Blog
Bits and Bytes from Microsoft UK
Entity Framework - Entity Provider Level. Entity SQL - NAVIGATE
Mike Taulty's Blog

Mike's Badges

Follow on Twitter
View mike's profile on slideshare
Add to Technorati Favorites
CW Blog Awards

Returning back to that list that I talked about in a previous post, we had

ANYELEMENT,CREATEREF, DEREF, IS OF, KEY, MULTISET, NAVIGATE, OFTYPE, OVERLAPS, Projection (including here as I've not yet figured out what it is :-)), REF, ROW , SELECT (including here because it has some weirdness like VALUE), SET, TREAT, USING

For this post, let's take a look at;

NAVIGATE

We've seen this already really.It looks to take the form of;

NAVIGATE( instance-expression, relationship-type, to-end, from-end )

but you can shorten it down by missing off the last 2 parameters if they are unambiguous.

What you get back as the result of a NAVIGATE is a collection(REF) so you've got a number of REFs rather than actual entities. So, we can query with something like this;

"select navigate(c, Northwind.FK_Orders_Customers, Orders, Customers) from NorthwindContext.Customers as c"

Now, I have to say that I found that syntax counter-intuitive in that the to end of the relationship is listed before the from end of the relationship. I expect to list from->to, not to->from but there you go. The shorter syntax makes it easier;

"select navigate(c, Northwind.FK_Orders_Customers) from NorthwindContext.Customers as c"

Now, I got quite puzzled as to what comes back from these queries. In so far as I can tell you get rows that look like;

row ( multiset ( ref ( Northwind.Order ) ) )

and if you were to do something like;

"select value navigate(c, Northwind.FK_Orders_Customers) from NorthwindContext.Customers as c"

then I think you get rows that look like;

multiset ( ref ( Northwind.Order ) )

Not 100% sure but I think that's what you get. Now, if you take another (way more obvious) route and use a navigation property then you'd write something like;

"select value c.orders from NorthwindContext.Customers as c"

and I think what you get then is;

multiset ( Northwind.Order )

I spent quite a bit of time (i.e. hours) trying to figure out how to get the navigate syntax to give me the equivalent result-set and I think, in the end I figured it out as something like;

select
    value deref(o)
from
    NorthwindContext.Customers as c,
    navigate(c, Northwind.FK_Orders_Customers) as o

That is, I think that "magic" comes from using navigate as part of a cross-product here in the from clause - I'll post more on that at a later point as/when I figure it out better.


Posted Mon, Aug 27 2007 3:56 PM by mtaulty

Comments

Mike Taulty's Blog wrote Entity Framework - Entity Provider Level. Entity SQL - Finishing Up for Now
on Mon, Aug 27 2007 4:15 PM
Returning back to that list that I talked about in a previous post, we had  ANYELEMENT,CREATEREF, DEREF,...
Mike Taulty's Blog wrote ADO.NET Entity Framework - Bringing Together A Few Previous Posts
on Wed, Aug 29 2007 5:37 PM
This is just a convenience - links to the posts that I've made so far around beta 2 of the ADO.NET Entity...
Entity Framework from Mike Taulty « vincenthome’s Software Development wrote Entity Framework from Mike Taulty « vincenthome’s Software Development
on Fri, Sep 7 2007 7:25 AM
(C) Mike Taulty, 2009. All rights reserved. The information in this weblog is provided "AS IS" with no warranties, and confers no rights. This weblog does not represent the thoughts, intentions, plans or strategies of my employer. It is solely my opinion. Inappropriate comments will be deleted at the authors discretion. All code samples are provided "AS IS" without warranty of any kind, either express or implied, including but not limited to the implied warranties of merchantability and/or fitness for a particular purpose.
Powered by Community Server (Non-Commercial Edition), by Telligent Systems