Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7087767
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T07:42:52+00:00 2026-05-28T07:42:52+00:00

Best title I could come up with, A little more involved however. // Hit

  • 0

Best title I could come up with, A little more involved however.

// Hit the database once and get all the categories;
IQueryable<Category> qryCategoryList = _repository.Select<Category>();

// get initial parents
var parentCategories = qryCategoryList.Where(x => x.ParentCategoryId == null);
foreach (Category parentCategory in parentCategories)
{
    HttpContext.Current.Response.Write(parentCategory.CategoryName = "This should not happen");
            BuildCategoryList(qryCategoryList, parentCategory.CategoryId);
}

This line

 HttpContext.Current.Response.Write(parentCategory.CategoryName = "This should not happen");

performs this

UPDATE Categories
SET    ParentCategoryId = NULL /* @p0_0 */,
       CategoryName = '->' /* @p1_0 */,
       CategoryDescription = 'The Fruit Category' /* @p2_0 */,
       Active = 1 /* @p3_0 */,
       DateCreated = '2012-01-20T12:03:41.00' /* @p4_0 */,
       LastUpdated = '2012-01-20T12:03:41.00' /* @p5_0 */
WHERE  CategoryId = 'aa8ca9ba-663c-45c8-950b-159a28e6635d' /* @p6_0 */

I am not calling save from my repository not wanting to do an update. How is this possible?

EDIT: Here is the mapping

 public class CategoryMap : ClassMap<Category>
{
    public CategoryMap()
    {
        Table("Categories");
        LazyLoad();
        Id(x => x.CategoryId).GeneratedBy.GuidComb().Column("CategoryId");
        Map(x => x.ParentCategoryId).Column("ParentCategoryId");
        Map(x => x.CategoryName).Column("CategoryName").Not.Nullable().Length(50);
        Map(x => x.CategoryDescription).Column("CategoryDescription").Not.Nullable();
        Map(x => x.Active).Column("Active").Not.Nullable();
        Map(x => x.DateCreated).Column("DateCreated").Not.Nullable();
        Map(x => x.LastUpdated).Column("LastUpdated").Not.Nullable();
        HasMany(x => x.PostingsCategories).KeyColumn("CategoryId");
    }
}
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-28T07:42:53+00:00Added an answer on May 28, 2026 at 7:42 am

    This usually happens when something in the mapping or object declaration doesn’t quite jive with what’s in the database. For example, you might have a UNIQUEIDENTIFIER in the database that’s nullable but mapped that to a non-nullable Guid on an object. NHibernate selects, sees a Guid.Empty instead of a null, and says “Hey! The object changed! Whelp, reckon I should update it…”

    That’s just one case of how it can happen. If you post your mapping, we might be able to help you debug it a bit further.

    —

    Actually, I should have read it a bit further. If this is within the scope of a transaction, NHibernate will auto update any changed entities without needing an explicit call to SaveOrUpdate(). It’s called autoflush and it’s on by default. You’ll need to set the FlushMode to Never if you want to explicitly call transaction.Commit() or session.Flush().

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

The title is a bit wonky but it's the best I could come up
As this question is hard to describe, that's the best title i could come
What could be the best way to achieve a functionality that All items get
First, I'm sorry about the title, that was the best I could come up
Sorry about the title. That was the best I could come up with. Anyways,
Firstly, the title was the best I could come up with. I have written
That title's a little tricky... When I'm writing an interface, is it generally best
Sorry for the terrible title, best I could think of at the time! Say
(Not sure if this title is the best description...) Hi all. I need a
(If my title is misleading/incorrect please suggest something more descriptive, that the best I

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.