Does the UPDATE statement actually change something? One thing I can
think of is a NULL in a varchar column somewhere being coerced into an
empty string, which NHibernate then sees as a dirty object. Or the
other way around. Does this happen even if you comment out the two
rows involving dlContact, but call ToList() on contacts to force it to
"materialize"?

/Oskar


2009/6/29 Brian Sullivan <bmsulli...@gmail.com>:
>
> I'm starting to play with NHibernate to make a case for its use in our
> company's projects. I've created a branch of one of our solutions and
> have started to convert some of the data access to using NHibernate as
> a proof-of-concept. However, while looking at SQL Profiler, I
> discovered that NHibernate is issuing an update command to the
> database when I databind an IList that I get back from a Criteria
> query to a Datalist control. The Criteria query looks like this:
>
>  var contacts = session.Get<Location>(LocationId).Contacts
>                .OrderBy(x => x.LastName)
>                .ThenBy(x => x.FirstName)
>                .ThenBy(x => x.ContactType.TypeName)
>                .ThenBy(x => x.ContactID);
>  dlContact.DataSource = contacts;
>  dlContact.DataBind();
> I'm getting the list of contacts that are associated with a particular
> location in our system. To be clear, the update does not seem to be
> issued right as DataBind() is called, but when the session is flushed
> at the end of the request. It issues an update to the Contacts table,
> not the Location table. And it's a single update, too, not one update
> for each contact associated with the location.
>
> Why does NHibernate think it needs to update the database? Is the
> databinding changing the value of one of the Contact entities returned
> from the query somehow? I'm just displaying the values on the page,
> not changing them anywhere that I can tell.
>
> Any help would be much appreciated. I can provide more code context if
> it would be helpful.
>
> >
>

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"nhusers" group.
To post to this group, send email to nhusers@googlegroups.com
To unsubscribe from this group, send email to 
nhusers+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/nhusers?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to