﻿<?xml version="1.0" encoding="utf-8"?><rss version="2.0"><channel><title>Ayende @ Rahien</title><link>http://ayende.com</link><description>Ayende @ Rahien</description><copyright>Copyright (C) Ayende Rahien  2004 - 2021 (c) 2026</copyright><ttl>60</ttl><item><title>Ayende Rahien commented on Analyzing the MVC Music Store: Data Access</title><description>Tim,
  
The code execute a Linq query, EF execute that query.
</description><link>http://ayende.com/4505/analyzing-the-mvc-music-store-data-access#comment29</link><guid>http://ayende.com/4505/analyzing-the-mvc-music-store-data-access#comment29</guid><pubDate>Sat, 22 May 2010 17:02:32 GMT</pubDate></item><item><title>Tim commented on Analyzing the MVC Music Store: Data Access</title><description>Looking at the AddToCart method where you replace the album instance with the int, I have one question.  Why is the query being executed twice to get the album?  Without your profiler, I would never guess there are two queries.  I would have thought that since the album object is already populated, the album id would be pulled from the property.  Is this due to how EF works, or is it due to Linq?  Just curious and nice and informative post.
</description><link>http://ayende.com/4505/analyzing-the-mvc-music-store-data-access#comment28</link><guid>http://ayende.com/4505/analyzing-the-mvc-music-store-data-access#comment28</guid><pubDate>Sat, 22 May 2010 16:57:58 GMT</pubDate></item><item><title>Andrey Shchekin commented on Analyzing the MVC Music Store: Data Access</title><description>I would say that it is kind of related to the weaknesses of EF. I wouldn't rewrite any NH-backed logic to take an Id, I would use Load instead. (In fact Id is not a part of the domain anyway).
  
  
I would also say that the main WTF there is that shopping cart has a reference to the datacontext. And actually uses it.
</description><link>http://ayende.com/4505/analyzing-the-mvc-music-store-data-access#comment27</link><guid>http://ayende.com/4505/analyzing-the-mvc-music-store-data-access#comment27</guid><pubDate>Tue, 18 May 2010 05:59:35 GMT</pubDate></item><item><title>jmorris commented on Analyzing the MVC Music Store: Data Access</title><description>Oren - 
  
  
I must admit the profiler is a pretty slick tool. I am _not_ looking forward to using it on some of code I own and discovering the undesirables  ;)
  
  
</description><link>http://ayende.com/4505/analyzing-the-mvc-music-store-data-access#comment26</link><guid>http://ayende.com/4505/analyzing-the-mvc-music-store-data-access#comment26</guid><pubDate>Tue, 18 May 2010 04:06:13 GMT</pubDate></item><item><title>Frank Quednau commented on Analyzing the MVC Music Store: Data Access</title><description>"For example, payroll calculation should be in the employee"
  
  
Payroll calculation clearly is a collaborative effort between the HR singleton and the management flyweights, with some random fluctuation coming from the employee's IEnumerable(Of Achievement).
</description><link>http://ayende.com/4505/analyzing-the-mvc-music-store-data-access#comment25</link><guid>http://ayende.com/4505/analyzing-the-mvc-music-store-data-access#comment25</guid><pubDate>Mon, 17 May 2010 21:35:52 GMT</pubDate></item><item><title>Jimmy commented on Analyzing the MVC Music Store: Data Access</title><description>EF, bleh... when is NH 3.0 going to be out?
</description><link>http://ayende.com/4505/analyzing-the-mvc-music-store-data-access#comment24</link><guid>http://ayende.com/4505/analyzing-the-mvc-music-store-data-access#comment24</guid><pubDate>Mon, 17 May 2010 15:17:13 GMT</pubDate></item><item><title>Ajai Shankar commented on Analyzing the MVC Music Store: Data Access</title><description>Thanks for the link Ayende!
  
  
Looks like the EF, L2S code generation camp were not that far off with their partial method stuff!
  
  
Just kidding :-)
  
  
Liked the mixin comments by the re-motion guys...
  
  
Ajai
</description><link>http://ayende.com/4505/analyzing-the-mvc-music-store-data-access#comment23</link><guid>http://ayende.com/4505/analyzing-the-mvc-music-store-data-access#comment23</guid><pubDate>Mon, 17 May 2010 15:11:15 GMT</pubDate></item><item><title>Ayende Rahien commented on Analyzing the MVC Music Store: Data Access</title><description>Ajai,
  
You probably want to read this:
  
[ayende.com/.../aspects-of-domain-design.aspx](http://ayende.com/Blog/archive/2008/11/23/aspects-of-domain-design.aspx)  
  
  
In short, there are several players here:
  
  
var salary = Employee.CalculateTotalSalary(month);
  
var afterTaxes = TaxService.ApplyTaxes(Employee, salary)
</description><link>http://ayende.com/4505/analyzing-the-mvc-music-store-data-access#comment22</link><guid>http://ayende.com/4505/analyzing-the-mvc-music-store-data-access#comment22</guid><pubDate>Mon, 17 May 2010 14:43:01 GMT</pubDate></item><item><title>Ajai Shankar commented on Analyzing the MVC Music Store: Data Access</title><description>@Ayende - just continuing on this discussion if you don't mind
  
  
"For example, payroll calculation should be in the employee"
  
  
What should be deposited into my account is my income tax withholding , other deductions such as medical insurance, dependent care etc.
  
  
So when doing DDD:
  
  
1. Do all these become properties/associations of the Employee class
  
  
2. Do we have variants of an Employee domain object depending on if it is the payroll module that is accessing it, or say organization chart module
  
  
3. Whatever you said about lazy loading etc in this post applies even more when you do an employee.CalculatePayroll (something out there has to be smart enough to eager load the empoyee with all the associations)
  
  
4. Finally does your domain make use of "services" - I am referring to say injecting services into domain classes
  
  
Ajai
  
  
  
  
  
  
</description><link>http://ayende.com/4505/analyzing-the-mvc-music-store-data-access#comment21</link><guid>http://ayende.com/4505/analyzing-the-mvc-music-store-data-access#comment21</guid><pubDate>Mon, 17 May 2010 14:32:06 GMT</pubDate></item><item><title>Ayende Rahien commented on Analyzing the MVC Music Store: Data Access</title><description>Eduardo,
  
They are true, I would suspect that Jeff executed his test on a local database. Because the cost of going to the database over the network is _very_ high
</description><link>http://ayende.com/4505/analyzing-the-mvc-music-store-data-access#comment20</link><guid>http://ayende.com/4505/analyzing-the-mvc-music-store-data-access#comment20</guid><pubDate>Mon, 17 May 2010 14:14:56 GMT</pubDate></item><item><title>William H commented on Analyzing the MVC Music Store: Data Access</title><description>&gt;Microsoft sample bashing seems to be fashion now.
  
  
Because historically Microsoft ASP.NET samples have been done in favor of showcasing the product rather on good design.  The ASP.NET 2.0 starter kits were a prime example of this.  When they were released they all had terrible performance issues right from the start that had to be fixed by the community.
</description><link>http://ayende.com/4505/analyzing-the-mvc-music-store-data-access#comment19</link><guid>http://ayende.com/4505/analyzing-the-mvc-music-store-data-access#comment19</guid><pubDate>Mon, 17 May 2010 13:39:14 GMT</pubDate></item><item><title>Ayende Rahien commented on Analyzing the MVC Music Store: Data Access</title><description>Ajai,
  
Everything that relates to the entity should be done internally.
  
For example, payroll calculation should be in the employee.
</description><link>http://ayende.com/4505/analyzing-the-mvc-music-store-data-access#comment18</link><guid>http://ayende.com/4505/analyzing-the-mvc-music-store-data-access#comment18</guid><pubDate>Mon, 17 May 2010 13:30:39 GMT</pubDate></item><item><title>Ajai Shankar commented on Analyzing the MVC Music Store: Data Access</title><description>Nice!
  
  
In this comment am referring to an earlier post about the sample app.
  
  
Taking an EF based app and saying "component based design should be retired" in the earlier post is a bit over the board!
  
  
And also mentioning COM in same sentence with EJB :-)
  
  
COM was all about interop, where as EJB entity beans etc was how somebody "thought" data ought to be done before Hibernate.
  
  
Had a question on the oft repeated topic of anemic domain models.
  
  
In your opinion what behavior do we exactly put in the domain?
  
  
All the examples I see is some customer.AddOrder (that most probably actually sets the order.Customer back-ref to keep NH happy)
  
  
Or say a derived property cart.Total that you unit-test based on items added to cart.
  
  
Anything more complex like say tax calculation you put in a service / "component"!
  
  
So where exactly do we draw the distinction between a data holder entity v/s true domain?
  
  
Ajai
  
  
  
  
  
  
  
  
  
</description><link>http://ayende.com/4505/analyzing-the-mvc-music-store-data-access#comment17</link><guid>http://ayende.com/4505/analyzing-the-mvc-music-store-data-access#comment17</guid><pubDate>Mon, 17 May 2010 13:09:44 GMT</pubDate></item><item><title>Ayende Rahien commented on Analyzing the MVC Music Store: Data Access</title><description>Paul,
  
Depending on how likely I thought that error to be. This sort of error? I would probably let it go to generic error page.
  
And in this case, it is a very rare error, only occurring if the user manually modified stuff. 
  
  
As for session management, I would handle that in an action filter. The same advice here applies for NH as well, you shouldn't have queries being generated from the view.
</description><link>http://ayende.com/4505/analyzing-the-mvc-music-store-data-access#comment16</link><guid>http://ayende.com/4505/analyzing-the-mvc-music-store-data-access#comment16</guid><pubDate>Mon, 17 May 2010 12:18:43 GMT</pubDate></item><item><title>Ayende Rahien commented on Analyzing the MVC Music Store: Data Access</title><description>Felipe,
  
I would introduce a Context per Request. This can be done via DI, via HttpContext.Current.Item["ObjectContext"} or however else you wish to do it
</description><link>http://ayende.com/4505/analyzing-the-mvc-music-store-data-access#comment15</link><guid>http://ayende.com/4505/analyzing-the-mvc-music-store-data-access#comment15</guid><pubDate>Mon, 17 May 2010 12:14:46 GMT</pubDate></item><item><title>Paul Cox commented on Analyzing the MVC Music Store: Data Access</title><description>Very enlightening view of EFProf. Impressive!
  
  
Would you just log the exception raised from the foreign key constraint in the global handler and redirect to a generic error page? When would you rely on foreign key constraints as opposed to an explicit business rule in the code?  
  
  
Would you also recommend no queries from the view? I've noticed "Open Session in View" being recommended as the way to handle NHibernate sessions in MVC. Is there a way to stop queries being fired from the view but still have commands (inserts/updates) fired at the end of the request?
</description><link>http://ayende.com/4505/analyzing-the-mvc-music-store-data-access#comment14</link><guid>http://ayende.com/4505/analyzing-the-mvc-music-store-data-access#comment14</guid><pubDate>Mon, 17 May 2010 12:11:15 GMT</pubDate></item><item><title>Frank Quednau commented on Analyzing the MVC Music Store: Data Access</title><description>This is so far away from sample bashing, I don't even have words for it. It is just an example to show off the analytical powers of the profiler that is so good that I almost feel like going home and never program again due to inferiority complex. An error like the select + 1 happens quite easily with the lazy loading features. This post shows a (very doable) way to find and avoid them.
  
The alerting system + Stack trace plain rocks. Great post!
</description><link>http://ayende.com/4505/analyzing-the-mvc-music-store-data-access#comment13</link><guid>http://ayende.com/4505/analyzing-the-mvc-music-store-data-access#comment13</guid><pubDate>Mon, 17 May 2010 12:08:28 GMT</pubDate></item><item><title>Felipe Fujiy commented on Analyzing the MVC Music Store: Data Access</title><description>Ayende, how do you share one context with all repositories? Use Dependency Injection with a per Request Life Manager?
  
  
About GetCartItems, putting Include will generate overhead to all calls, including when I dont need Albums
</description><link>http://ayende.com/4505/analyzing-the-mvc-music-store-data-access#comment12</link><guid>http://ayende.com/4505/analyzing-the-mvc-music-store-data-access#comment12</guid><pubDate>Mon, 17 May 2010 12:04:56 GMT</pubDate></item><item><title>Ayende Rahien commented on Analyzing the MVC Music Store: Data Access</title><description>Paul,
  
TekPub has a series of videos on doing just that.
</description><link>http://ayende.com/4505/analyzing-the-mvc-music-store-data-access#comment11</link><guid>http://ayende.com/4505/analyzing-the-mvc-music-store-data-access#comment11</guid><pubDate>Mon, 17 May 2010 11:51:54 GMT</pubDate></item><item><title>Ayende Rahien commented on Analyzing the MVC Music Store: Data Access</title><description>Tobi,
  
What sample bashing? 
  
I put the sample through an analysis process, which I full shared.
  
I point out potential problems with the code and am fully transparent with how I found those problems. 
</description><link>http://ayende.com/4505/analyzing-the-mvc-music-store-data-access#comment10</link><guid>http://ayende.com/4505/analyzing-the-mvc-music-store-data-access#comment10</guid><pubDate>Mon, 17 May 2010 11:51:21 GMT</pubDate></item><item><title>Ayende Rahien commented on Analyzing the MVC Music Store: Data Access</title><description>Demis,
  
I meant, go to the url in the MVC Music Store application, and then see what queries are being generated in EF Prof.
</description><link>http://ayende.com/4505/analyzing-the-mvc-music-store-data-access#comment9</link><guid>http://ayende.com/4505/analyzing-the-mvc-music-store-data-access#comment9</guid><pubDate>Mon, 17 May 2010 11:49:56 GMT</pubDate></item><item><title>Paul Cowan commented on Analyzing the MVC Music Store: Data Access</title><description>I would love to see a video of Nhprof used like this to fully see it in action.
</description><link>http://ayende.com/4505/analyzing-the-mvc-music-store-data-access#comment8</link><guid>http://ayende.com/4505/analyzing-the-mvc-music-store-data-access#comment8</guid><pubDate>Mon, 17 May 2010 11:24:16 GMT</pubDate></item><item><title>tobi commented on Analyzing the MVC Music Store: Data Access</title><description>Microsoft sample bashing seems to be fashion now.
</description><link>http://ayende.com/4505/analyzing-the-mvc-music-store-data-access#comment7</link><guid>http://ayende.com/4505/analyzing-the-mvc-music-store-data-access#comment7</guid><pubDate>Mon, 17 May 2010 11:05:31 GMT</pubDate></item><item><title>PS commented on Analyzing the MVC Music Store: Data Access</title><description>Demis, the url is most likely for the web app being run from the visual studio development server...
</description><link>http://ayende.com/4505/analyzing-the-mvc-music-store-data-access#comment6</link><guid>http://ayende.com/4505/analyzing-the-mvc-music-store-data-access#comment6</guid><pubDate>Mon, 17 May 2010 11:04:43 GMT</pubDate></item><item><title>Chuck Bryan commented on Analyzing the MVC Music Store: Data Access</title><description>I really, really like post like this one. You were professionally reviewing a piece of code, showing how you use your tools and making small changes to remove some bad O/RM performance areas. Additionally, it is great to get a peek into your thought process and how you approach a problem.
</description><link>http://ayende.com/4505/analyzing-the-mvc-music-store-data-access#comment5</link><guid>http://ayende.com/4505/analyzing-the-mvc-music-store-data-access#comment5</guid><pubDate>Mon, 17 May 2010 10:51:33 GMT</pubDate></item><item><title>Demis Bellot commented on Analyzing the MVC Music Store: Data Access</title><description>Sorry, maybe I misunderstood what was going on:
  
  
&gt;&gt; Now, we go to 
[http://localhost:1397/](http://localhost:1397/), and we can see the following in EF Prof:
  
  
Are you loading the EF Prof UI from this url? or is it just the web app and you have EF Prof running side-by-side?
</description><link>http://ayende.com/4505/analyzing-the-mvc-music-store-data-access#comment4</link><guid>http://ayende.com/4505/analyzing-the-mvc-music-store-data-access#comment4</guid><pubDate>Mon, 17 May 2010 10:49:27 GMT</pubDate></item><item><title>Ayende Rahien commented on Analyzing the MVC Music Store: Data Access</title><description>I don't understand the question
</description><link>http://ayende.com/4505/analyzing-the-mvc-music-store-data-access#comment3</link><guid>http://ayende.com/4505/analyzing-the-mvc-music-store-data-access#comment3</guid><pubDate>Mon, 17 May 2010 10:43:55 GMT</pubDate></item><item><title>Demis Bellot commented on Analyzing the MVC Music Store: Data Access</title><description>How are you loading EF Prof from a url? is it a silverlight app? or have you registered a url scheme with the OS that you redirect to onload? or something else?
</description><link>http://ayende.com/4505/analyzing-the-mvc-music-store-data-access#comment2</link><guid>http://ayende.com/4505/analyzing-the-mvc-music-store-data-access#comment2</guid><pubDate>Mon, 17 May 2010 10:42:33 GMT</pubDate></item><item><title>marek commented on Analyzing the MVC Music Store: Data Access</title><description>Nice one Ayende :)
</description><link>http://ayende.com/4505/analyzing-the-mvc-music-store-data-access#comment1</link><guid>http://ayende.com/4505/analyzing-the-mvc-music-store-data-access#comment1</guid><pubDate>Mon, 17 May 2010 09:33:39 GMT</pubDate></item></channel></rss>