Application analysis: Northwind.NET
Join the DZone community and get the full member experience.Join For Free
for an article i am writing, i wanted to compare a ravendb model to a relational model, and i stumbled upon the following northwind.net project .
i plugged in the entity framework profiler and set out to watch what was going on. to be truthful, i expected it to be bad, but i honestly did not expect what i got. here is a question, how many queries does it take to render the following screen?
the answer, believe it or no, is 17:
you might have noticed that most of the queries look quite similar, and indeed, they are . we are talking about 16(!) identical queries:
select [extent1].[id] as [id], [extent1].[name] as [name], [extent1].[description] as [description], [extent1].[picture] as [picture], [extent1].[rowtimestamp] as [rowtimestamp] from [dbo].[category] as [extent1]
looking at the stack trace for one of those queries led me to:
and to this piece of code:
you might note that dynamic is used there, for what reason, i cannot even guess. just to check, i added a toarray() to the result of getentityset, and the number of queries dropped from 17 to 2, which is more reasonable. the problem was that we passed an iqueryable to the data binding engine, which ended up evaluating the query multiple times.
and ef prof actually warns about that, too:
at any rate, i am afraid that this project suffer from similar issues all around, it is actually too bad to serve as the bad example that i intended it to be.
Published at DZone with permission of Oren Eini, DZone MVB. See the original article here.
Opinions expressed by DZone contributors are their own.