Inline ->

> >> I've been doing this for about 3 hours, so I may have the wrong end of
> the
> >> stick.
> >>
> >> While doing the "hello world" type walkthrough I've come across....
> >>
> >>             ObjectQuery<Department> departmentQuery =
> >>                 schoolContext.Department.Include("Course")
> >>                 .OrderBy("it.Name");
> >>
> >> Now I'm a bit confused as to what an object query is, but this doesn't
> >> look nice...."Course" and "it.Name"...are going to give me runtime
> errors
> >> if (when) something changes.
> >>
> >> I'm a bit confused as to how this sits with Linq....is there a Linq
> query
> >> that I can use in the above which is typesafe and is of type
> >> ObjectQuery<Department>?
> >
> >        The '.Include("Course")' part won't be possible to make type safe,
> >unless you write your own extension method, pass in an entity type and
> return
> >a MethodCall expression to Include passing in the string. Why they haven't
> >done that is beyond me, also why they haven't added more eager loading
> options
> >like filters etc.
> >
> >        The .OrderBy can be rewritten as:
> >
> >        from d in schoolContext.Department.Include("Course")
> >        orderby d.Name ascending
> >        select d;
>
> OK, I thought you'd probably be able to do the order by, though my linq is
> not quite there I struggled with the OrderBy extension method for a thirty
> seconds and gave up on the grounds that it probably did work.

        I'd opt for the native C# syntax first and fall back to extension
methods if necessary, that way it will be easier in the long run :)

> The Include thing is odd to me, the big advantage (to me) of all this
> stuff is the type safety of database changes, but this include would seem
> to fall outside that, and there seems to be no obvious public way of
> getting hold of the 'behaviour' that knows about the relationship between
> Deparment and Course, if so an extension method would not be possible and
> I'd have to extend the class Department (assuming I can dig out some
> protected/private behaviour), but at this stage the biggest unknown is the
> extent of my ignorance.

        Yes, it's indeed odd. However, if you look at Astoria, the 'Include'
method fits in perfectly. I don't know for sure, but it is pretty obvious that
the .Include() signature is derived from the Astoria usage.

        You could try the extension method mentioned in another post in this
thread, it might work to some extend (pun intended) ;)

                FB

>
> Thanks anyway....it's not me then, I expect it will become typesafe in the
> future.
>
> >
> >        at least, that's how standard linq queries would do it.
> >
> >                FB
> >
> >
> >------------------------------------------------------------------------
> >Lead developer of LLBLGen Pro, the productive O/R mapper for .NET
> >LLBLGen Pro website: http://www.llblgen.com
> >My .NET blog: http://weblogs.asp.net/fbouma
> >Microsoft MVP (C#)
> >------------------------------------------------------------------------
> >
> >===================================
> >This list is hosted by DevelopMentorR  http://www.develop.com
> >
> >View archives and manage your subscription(s) at
> http://discuss.develop.com
>
> ===================================
> This list is hosted by DevelopMentorR  http://www.develop.com
>
> View archives and manage your subscription(s) at http://discuss.develop.com

===================================
This list is hosted by DevelopMentorĀ®  http://www.develop.com

View archives and manage your subscription(s) at http://discuss.develop.com

Reply via email to