locked
Getting parent entity data RRS feed

  • Question

  • I have an entity which has a parent record related by a foreign key i.e. a workitem can have many jobs.

     

    Dim f = (From t In ctx.Jobs Select t.JobId)

     

    When I go to get the parent data e.g.

     

     Dim f = (From t In ctx.Jobs Select t.JobId,t.WorkQueueItems.DateCreated)

     

    I get told DateCreated is not a member of the WorkQueueItems, the only thing that shows up in the intellisense are things like SUM and AGGREGATE. I need to get the parent info.

     

    How do I do this? Regards, Chris.

    Friday, September 26, 2008 4:29 PM

Answers

  • From looking at it without any schema, it looks like WorkQueueItems is a collection.  You are trying to select a DateCreated from a collection instead of from a record, that is why you see collection related items in the intellisense and not the column names.  You need to flatten it out.  Something like:

     

    from j in ctx.Jobs

    from w in j.WorkQueueItems

    select j.JobId, w.DateCreated

     

    BTW - Is Chris and Fresno Bob same person?

     

     

    Sunday, September 28, 2008 12:35 AM

All replies

  • From looking at it without any schema, it looks like WorkQueueItems is a collection.  You are trying to select a DateCreated from a collection instead of from a record, that is why you see collection related items in the intellisense and not the column names.  You need to flatten it out.  Something like:

     

    from j in ctx.Jobs

    from w in j.WorkQueueItems

    select j.JobId, w.DateCreated

     

    BTW - Is Chris and Fresno Bob same person?

     

     

    Sunday, September 28, 2008 12:35 AM
  • Cheers I'll look forward to trying that out tomorrow. Yes Fresno Bob and Chris are the same - it's just on lots of forums my name is taken, Oddly enough Fresno Bob isn't.....

    Sunday, September 28, 2008 8:15 AM