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

  • Home
  • SEARCH
  • 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 8376147
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 9, 20262026-06-09T15:21:35+00:00 2026-06-09T15:21:35+00:00

I’m thinking an enum might be the way to go, and depending on the

  • 0

I’m thinking an enum might be the way to go, and depending on the action (create, delete) it replaces the characters? Then I’d have to store a variable for “–“, “++”, “>=” and “>” hrrmm. Any simple suggestions would be great, and I could use it as a future reference as to how I might tackle a problem like this!

public void ArrangeCategoriesOrderOnCreate(Category category)
{
    var tx = _session.BeginTransaction();
    var categories = _session.QueryOver<Category>()
        .Where(c => c.Parent.Id == category.Parent.Id && c.OrderInList >= category.OrderInList) // the >= category.OrderInList here
        .List<Category>();

    foreach(var item in categories)
    {
        item.OrderInList++; // The ++ here.
        _session.SaveOrUpdate(item);
    }
    tx.Commit();
}

public void ArrangeCategoriesOrderOnDelete(Category category)
{
    var tx = _session.BeginTransaction();
    var categories = _session.QueryOver<Category>()
        .Where(c => c.Parent.Id == category.Parent.Id && c.OrderInList > category.OrderInList) // the > category.OrderInList here
        .List<Category>();

    foreach(var item in categories)
    {
        item.OrderInList--; // the -- here.
        _session.SaveOrUpdate(item);
    }
    tx.Commit();
}

Edit 1

Could not determine member type from Invoke, Invoke(value(CumbriaMD.Infrastructure.DataServices.CategoryDataServices+<>c_DisplayClass8).orderComparer, c.OrderInList, value(CumbriaMD.Infrastructure.DataServices.CategoryDataServices+<>c_DisplayClass8).category.OrderInList), System.Linq.Expressions.InvocationExpression

Trace:

[Exception: Could not determine member type from Invoke, Invoke(value(CumbriaMD.Infrastructure.DataServices.CategoryDataServices+<>c_DisplayClass8).orderComparer, c.OrderInList, value(CumbriaMD.Infrastructure.DataServices.CategoryDataServices+<>c_DisplayClass8).category.OrderInList), System.Linq.Expressions.InvocationExpression]
NHibernate.Impl.ExpressionProcessor.ProcessBooleanExpression(Expression expression) +1113
NHibernate.Impl.ExpressionProcessor.ProcessExpression(Expression expression) +114
NHibernate.Impl.ExpressionProcessor.ProcessAndExpression(BinaryExpression expression) +85
NHibernate.Impl.ExpressionProcessor.ProcessBinaryExpression(BinaryExpression expression) +124
NHibernate.Impl.ExpressionProcessor.ProcessExpression(Expression expression) +95
NHibernate.Impl.ExpressionProcessor.ProcessLambdaExpression(LambdaExpression expression) +52
NHibernate.Impl.ExpressionProcessor.ProcessExpression(Expression1 expression) +39
NHibernate.Criterion.QueryOver
2.Add(Expression1 expression) +107
NHibernate.Criterion.QueryOver
2.Where(Expression1 expression) +42
NHibernate.Criterion.QueryOver
2.NHibernate.IQueryOver.Where(Expression`1 expression) +42

  • 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-06-09T15:21:37+00:00Added an answer on June 9, 2026 at 3:21 pm

    One simple way to start would be to just break out the common functionality using a Func for the difference and get rid of most of the duplication.

    public void ArrangeCategoriesOrderOnCreate(Category category)
    {
        ArrangeCategoriesOrderOnAction(category, (a,b) => a>=b, x => x + 1);
    }
    
    public void ArrangeCategoriesOrderOnDelete(Category category)
    {
        ArrangeCategoriesOrderOnAction(category, (a,b) => a>b, x => x - 1);
    }
    
    public void ArrangeCategoriesOrderOnAction(Category category, 
                                   Expression<Func<int, int, bool>> orderComparer,
                                   Func<int, int> orderUpdateCalculator)
    {
        var tx = _session.BeginTransaction();
        var categories = _session.QueryOver<Category>()
            .Where(c => c.Parent.Id == category.Parent.Id 
                   && orderComparer(c.OrderInList, category.OrderInList))
            .List<Category>();
    
        foreach (var item in categories)
        {
            item.OrderInList = orderUpdateCalculator(item.OrderInList);
            _session.SaveOrUpdate(item);
        }
        tx.Commit();
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

link Im having trouble converting the html entites into html characters, (&# 8217;) i
I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function
I have a text area in my form which accepts all possible characters from
I have a .ini file as follows: [playlist] numberofentries=2 File1=http://87.230.82.17:80 Title1=(#1 - 365/1400) Example
I have just tried to save a simple *.rtf file with some websites and
I want to count how many characters a certain string has in PHP, but
I used javascript for loading a picture on my website depending on which small
I have a jquery bug and I've been looking for hours now, I can't
Basically, what I'm trying to create is a page of div tags, each has
this is what i have right now Drawing an RSS feed into the php,

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.