0

I'm trying to do a fairly simple linq join like so:

var locations = (from location in session.Query<Location>()

                join speed in session.Query<ISDNSpeeds>() on location.ISDNSpeed equals speed.Id
                where 

                  (location.LastUpdatedTime > lastUpdateTime)

                select new
                {
                    Location = location,
                    Speed = speed,
                })
                .Take(10).ToList();

It seems to run without error, but I can't access the Speed object, I just get a list of location objects.

How would I access speed in this case?

Positonic
  • 9,151
  • 14
  • 57
  • 84
  • You're saying there's no "locations.First().Speed" ? property on your anonymous type? – Dave Bish May 11 '12 at 09:04
  • How are you accessing your Speed property? Can you show us the code you're using for that please. Also, the `x` at the end there, is that just a typo? – Jamie Dixon May 11 '12 at 09:05
  • @DaveBish yes, that's what I'm saying, I'm new to this, so may be missing something obvious – Positonic May 11 '12 at 09:39
  • It's ISDN, so you'll probably have to wait longer for the speed object to arrive. Apart from that, did you check (and run) the SQL that was generated? – Gert Arnold May 12 '12 at 17:42

2 Answers2

0

You are getting a list of object in locations where you have property Location and Speed. Try Console.WriteLine(locations.First().Speed);

Habib
  • 219,104
  • 29
  • 407
  • 436
0

Your code is basically the same as the first example (Customers/Orders) on this page:

http://www.hookedonlinq.com/JoinOperator.ashx

So the code you're using to access the results is probably wrong somewhere.

Daniel Earwicker
  • 114,894
  • 38
  • 205
  • 284