Include in enity framework 4

Posted by molgan on Stack Overflow See other posts from Stack Overflow or by molgan
Published on 2010-06-09T09:11:19Z Indexed on 2010/06/09 12:42 UTC
Read the original article Hit count: 174

Hello

I've been using enity framework that came with 3.5sp. And now I've redone things for enityframework 4 and asp.net mvc 2. I've come across something (which worked in my previous version and asp.net mvc 1.0).

I have this:

public IQueryable<Booking> GetBookings()
{

   return from b in _entities.Bookings.Include("BookingObject")
          select b;
}

And in my controller I have:

return View("Index", new BookingsViewModel
        {
            Bookings = _br.GetBookings().ByDay(DateTime.Today)
        });

And it doesnt seem to include the "BookingObject"-entity, so I can type like <%= Model.Bookings.BookingObject.BookingObjectName %> in my view.

What might be missing here? Do I need to turn something on in the diagram for it to include entities or?

/M

© Stack Overflow or respective owner

Related posts about asp.net-mvc

Related posts about entity-framework