I am using Entity Framework and Linq to Entitites.
I would like to know if there is any way in Visual Studio 2012 to debug this code, step by step. At the moment when placing a break point, the cursor goes over it but does not step inside.
I am more interested to see the value of x.e... not the sql generated for example.
Notes: I'm fine with using other tools or Visual Studio plugins.
IEnumerable<EventPushNotification> eventToPushCollage = eventsForEvaluation
.GroupJoin(eventCustomRepository.FindAllPushedEvents(),
e => e.Id,
p => p.PushedEventId,
(e, p) => new { e, p })
.Where(x => x.e.DateTimeStart > currentDateTime &&
currentDateTime >= x.e.DateTimeStart.AddMinutes(defaultReminders) && // Data from default reminder for collage event in web.config
x.p.Count() == 0) // Check if the Event has not being already pushed
.Select(y => new EventPushNotification
{
Id = y.e.Id,
EventTitle = y.e.EventTitle,
DateTimeStart = y.e.DateTimeStart,
DateTimeEnd = y.e.DateTimeEnd,
Location = y.e.Location,
Description = y.e.Description,
DeviceToken = y.e.DeviceToken
});
You can add breakpoints on any of your own code.
So put the cursor at 'x.e', and press F9.
You can't debug a Lambda expression if you're using a Linq to Entities provider.
But you can take a look at what SQL it translate into. Also if you are willing to suffer a performance hit - you could load it all into Linq to obejcts - and do a Step by step
Make sure you read the official MSDN doc on this matter:
Debugging LINQ
and please vote for this suggestion on Visual Studio's User Voice page:
Debug Lambda expressions
Allon Guralnek comments on March 18, 2014 12:37 PM about a way of setting a breakpoint with the keyboard only:
Here's it in action in my current Visual Studio 2013:
As you can see it works pretty well and allows us to see the value of a given property being tested. This is for sure an awesome tool/life saver! :)
I don't know how to this directly in Visual Studio, but you should have a look at LinqPad: http://www.linqpad.net/
No there is no way to see values of
x
nore
variables because linq to orm is not executed it is translated/interpreted to generate an sql query.The debug run on function called with lambda expression if you use ToList().
Example