On Tue, 26 Aug 2008 15:58:44 +0200, Frans Bouma <[EMAIL PROTECTED]> wrote:

Hello,

We've talked about all this before I seem to remember, this entity
framework stuff is more what I'm after, though I'm slightly confused by
some of it.


>> 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.

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.

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 DevelopMentorĀ®  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