Ayende @ Rahien

It's a girl

Profiler new features: Data binding alerts

The following features apply to NHProf, EFProf, L2SProf.

In general, it is strong discouraged to data bind directly to an IQueryable. Mostly, that is because data binding may actually iterate over the IQueryable several times, resulting in multiple queries being generated from something that can be done purely in memory. Worse, it is actually pretty common for data binding to result in lazy loading, and lazy loading from data binding almost always result in SELECT N+1. The profiler can now detect and warn you about such mistakes preemptively. More than that, the profiler can also now detect queries that are being generated from the views in an ASP.Net MVC application, another bad practice that I don’t like.

You can find more information about each warnings here:

WPF detection:

image

 

image

WinForms detections:

image

image

Web applications:

image

image

Comments

tobi
09/27/2010 10:10 AM by
tobi

A nice step to counteract the counterproductive trend in the .NET world to rely on such practices for dubious code savings.

configurator
09/27/2010 12:47 PM by
configurator

So that's why you needed to look at the stack trace!

José F. Romaniello
09/27/2010 12:59 PM by
José F. Romaniello

Can you detect if a lazy property was initialized because a databinding?

that will be really useful.

thanks

Ayende Rahien
09/27/2010 01:42 PM by
Ayende Rahien

Jose,

Yes, that will detect this as well

Nigel Sampson
09/27/2010 07:29 PM by
Nigel Sampson

Very cool, I ended up handling this by disposing of my unit of work at the end of the action (through an ActionFilter) which means that any lazy evaluation in the view throws an exception.

Cheers

anon
09/28/2010 07:45 AM by
anon

efprof-735 throws bad image format exception on my xp machine.

Ayende Rahien
09/28/2010 07:46 AM by
Ayende Rahien

Anon,

Yes, there was an issue with uploading to the server.

Build 738 fixes the issue

Comments have been closed on this topic.