﻿<?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>RichB commented on New Profiler Feature: Avoid Writes from Multiple Sessions In The Same Request</title><description>What would happen if a single web request updated data in multiple sessions, but they were against different data sources? eg different servers, different databases or even different DB schemas?
  
  
I would expect that scenario to not report an error.
  
  
Having multiple schemas in the same database is very useful for partitioning the security domain from application domain in a defense-in-depth way. Yet both domains may need to be updated in the same request.
</description><link>http://ayende.com/4775/new-profiler-feature-avoid-writes-from-multiple-sessions-in-the-same-request#comment10</link><guid>http://ayende.com/4775/new-profiler-feature-avoid-writes-from-multiple-sessions-in-the-same-request#comment10</guid><pubDate>Mon, 21 Mar 2011 12:36:18 GMT</pubDate></item><item><title>Ayende Rahien commented on New Profiler Feature: Avoid Writes from Multiple Sessions In The Same Request</title><description>Govind,
  
If you are using the ORM properly, it is not an issue
</description><link>http://ayende.com/4775/new-profiler-feature-avoid-writes-from-multiple-sessions-in-the-same-request#comment9</link><guid>http://ayende.com/4775/new-profiler-feature-avoid-writes-from-multiple-sessions-in-the-same-request#comment9</guid><pubDate>Thu, 10 Mar 2011 21:02:58 GMT</pubDate></item><item><title>Govind commented on New Profiler Feature: Avoid Writes from Multiple Sessions In The Same Request</title><description>Should this not be closer to db in a stored proc where multiple connection problem does not arise?
</description><link>http://ayende.com/4775/new-profiler-feature-avoid-writes-from-multiple-sessions-in-the-same-request#comment8</link><guid>http://ayende.com/4775/new-profiler-feature-avoid-writes-from-multiple-sessions-in-the-same-request#comment8</guid><pubDate>Thu, 10 Mar 2011 14:57:30 GMT</pubDate></item><item><title>flukus commented on New Profiler Feature: Avoid Writes from Multiple Sessions In The Same Request</title><description>I find this everywhere people are using MS Enterprise Library. Every method of every DAO will contain Database.CreateConnection().
  
  
I much prefer having the connection passed around explicitly instead of hidden away,
</description><link>http://ayende.com/4775/new-profiler-feature-avoid-writes-from-multiple-sessions-in-the-same-request#comment7</link><guid>http://ayende.com/4775/new-profiler-feature-avoid-writes-from-multiple-sessions-in-the-same-request#comment7</guid><pubDate>Wed, 02 Mar 2011 09:56:23 GMT</pubDate></item><item><title>Rafal commented on New Profiler Feature: Avoid Writes from Multiple Sessions In The Same Request</title><description>If someone doesn't understand how to handle transactions he shouldn't be allowed to write any code. So maybe the next useful function would be to make profiler find such guys and exterminate them. Ayende, how does this fit into your design?
</description><link>http://ayende.com/4775/new-profiler-feature-avoid-writes-from-multiple-sessions-in-the-same-request#comment6</link><guid>http://ayende.com/4775/new-profiler-feature-avoid-writes-from-multiple-sessions-in-the-same-request#comment6</guid><pubDate>Wed, 02 Mar 2011 08:55:44 GMT</pubDate></item><item><title>NC commented on New Profiler Feature: Avoid Writes from Multiple Sessions In The Same Request</title><description>Don't use Query
&lt;t, it's highly buggy. 
  
  
Using MAX/MIN causes it to do casting, using the Criteria stuff it works perfectly. Theres too many bugs around Query, it's definitely not ready for production.
&gt;</description><link>http://ayende.com/4775/new-profiler-feature-avoid-writes-from-multiple-sessions-in-the-same-request#comment5</link><guid>http://ayende.com/4775/new-profiler-feature-avoid-writes-from-multiple-sessions-in-the-same-request#comment5</guid><pubDate>Tue, 01 Mar 2011 21:24:31 GMT</pubDate></item><item><title>Pl&amp;#225;cido Bisneto commented on New Profiler Feature: Avoid Writes from Multiple Sessions In The Same Request</title><description>Your blog has removed the "greater than" and "less than" from my post.
  
I was using the generic method Query() and FetchMany()
  
  
:)
</description><link>http://ayende.com/4775/new-profiler-feature-avoid-writes-from-multiple-sessions-in-the-same-request#comment4</link><guid>http://ayende.com/4775/new-profiler-feature-avoid-writes-from-multiple-sessions-in-the-same-request#comment4</guid><pubDate>Tue, 01 Mar 2011 16:49:56 GMT</pubDate></item><item><title>Pl&amp;#225;cido Bisneto commented on New Profiler Feature: Avoid Writes from Multiple Sessions In The Same Request</title><description>Hi!
  
Sorry for the delay... The SQL statements are the same...
  
The LINQ query is:
  
  
				var loginResult = (from u in this.Context.Session.Query
&lt;user()
  
								   where u.Login == username &amp;&amp; u.Password == password
  
								   select u)
  
								   .FetchMany
&lt;user,&gt;
(z =&gt; z.Wallets)
  
								   .SingleOrDefault();
  
  
just changing the Single for First....
  
  
This is the SQL generated using SingleOrDefault():
  
  
select user0_.UserId                  as InvestorId4_0_,
  
       wallets1_.WalletId             as WalletId8_1_,
  
       user0_1_.Version               as Version4_0_,
  
       user0_1_.CreatedOn             as CreatedOn4_0_,
  
       user0_.FirstName               as FirstName6_0_,
  
       user0_.LastName                as LastName6_0_,
  
       user0_.Email                   as Email6_0_,
  
       user0_.LastLogOn               as LastLogOn6_0_,
  
       user0_.CreatedOn               as CreatedOn6_0_,
  
       user0_.UpdatedOn               as UpdatedOn6_0_,
  
       user0_.Login                   as Login6_0_,
  
       user0_.Password                as Password6_0_,
  
       user0_.RecoveryPasswordEmail   as Recover10_6_0_,
  
       wallets1_.CreatedOn            as CreatedOn8_1_,
  
       wallets1_.UpdatedOn            as UpdatedOn8_1_,
  
       wallets1_.WalletDescription    as WalletDe4_8_1_,
  
       wallets1_.WalletName           as WalletName8_1_,
  
       wallets1_.WaintingForOperation as Wainting6_8_1_,
  
       wallets1_.CreationValue        as Creation7_8_1_,
  
       wallets1_.CurrentBalance       as CurrentB8_8_1_,
  
       wallets1_.InvestorId           as InvestorId8_1_,
  
       wallets1_.InvestorId           as InvestorId0__,
  
       wallets1_.WalletId             as WalletId0__
  
from   Users user0_
  
       inner join Investors user0_1_
  
         on user0_.UserId = user0_1_.InvestorId
  
       left outer join Wallets wallets1_
  
         on user0_.UserId = wallets1_.InvestorId
  
where  user0_.Login = 'cidico' /* :p0 */
  
       and user0_.Password = '123' /* :p1 */
  
  
  
---------------------------------------------------------------------------------
  
  
This is the SQL generated using FirstOrDefault():
  
  
select user0_.UserId                  as InvestorId4_0_,
  
       wallets1_.WalletId             as WalletId8_1_,
  
       user0_1_.Version               as Version4_0_,
  
       user0_1_.CreatedOn             as CreatedOn4_0_,
  
       user0_.FirstName               as FirstName6_0_,
  
       user0_.LastName                as LastName6_0_,
  
       user0_.Email                   as Email6_0_,
  
       user0_.LastLogOn               as LastLogOn6_0_,
  
       user0_.CreatedOn               as CreatedOn6_0_,
  
       user0_.UpdatedOn               as UpdatedOn6_0_,
  
       user0_.Login                   as Login6_0_,
  
       user0_.Password                as Password6_0_,
  
       user0_.RecoveryPasswordEmail   as Recover10_6_0_,
  
       wallets1_.CreatedOn            as CreatedOn8_1_,
  
       wallets1_.UpdatedOn            as UpdatedOn8_1_,
  
       wallets1_.WalletDescription    as WalletDe4_8_1_,
  
       wallets1_.WalletName           as WalletName8_1_,
  
       wallets1_.WaintingForOperation as Wainting6_8_1_,
  
       wallets1_.CreationValue        as Creation7_8_1_,
  
       wallets1_.CurrentBalance       as CurrentB8_8_1_,
  
       wallets1_.InvestorId           as InvestorId8_1_,
  
       wallets1_.InvestorId           as InvestorId0__,
  
       wallets1_.WalletId             as WalletId0__
  
from   Users user0_
  
       inner join Investors user0_1_
  
         on user0_.UserId = user0_1_.InvestorId
  
       left outer join Wallets wallets1_
  
         on user0_.UserId = wallets1_.InvestorId
  
where  user0_.Login = 'cidico' /* :p0 */
  
       and user0_.Password = '123' /* :p1 */
&gt;</description><link>http://ayende.com/4775/new-profiler-feature-avoid-writes-from-multiple-sessions-in-the-same-request#comment3</link><guid>http://ayende.com/4775/new-profiler-feature-avoid-writes-from-multiple-sessions-in-the-same-request#comment3</guid><pubDate>Tue, 01 Mar 2011 16:47:36 GMT</pubDate></item><item><title>Ayende Rahien commented on New Profiler Feature: Avoid Writes from Multiple Sessions In The Same Request</title><description>Bisneto,
  
What SQL is generated for each?
</description><link>http://ayende.com/4775/new-profiler-feature-avoid-writes-from-multiple-sessions-in-the-same-request#comment2</link><guid>http://ayende.com/4775/new-profiler-feature-avoid-writes-from-multiple-sessions-in-the-same-request#comment2</guid><pubDate>Tue, 01 Mar 2011 14:23:17 GMT</pubDate></item><item><title>Pl&amp;#225;cido Bisneto commented on New Profiler Feature: Avoid Writes from Multiple Sessions In The Same Request</title><description>Ayende,
  
  
I don't know if it's a "problem" in the NHProf, but when using LINQ to perform queries, when I use the FirstOrDefault(), the profiller shows me an alert saying that "the min/max number of records was not specified. doing it in memory". It does not happen when I use SingleOrDefault().
  
  
Is it the expected behaviour??
</description><link>http://ayende.com/4775/new-profiler-feature-avoid-writes-from-multiple-sessions-in-the-same-request#comment1</link><guid>http://ayende.com/4775/new-profiler-feature-avoid-writes-from-multiple-sessions-in-the-same-request#comment1</guid><pubDate>Tue, 01 Mar 2011 12:40:20 GMT</pubDate></item></channel></rss>