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 4043448
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 20, 20262026-05-20T13:07:41+00:00 2026-05-20T13:07:41+00:00

I have code which works perfect, BUT if I select to much results, it

  • 0

I have code which works perfect, BUT if I select to much results, it throw GenericADOException.

There is SQL which is genereted by Hibernate:

SELECT  this_.Value as y0_, 
        this_1_.OrderNumber as y1_, 
        count(*) as y2_ 
FROM    DotaznikySpokojenosti.dbo.QuestionRateDTO this_ 
        inner join DotaznikySpokojenosti.dbo.QuestionDTO this_1_ 
        on this_.QuestionRateID=this_1_.ID 
WHERE this_1_.Questinary in (@p0, @p1, @p2, @p3, ... , @p2876) 
GROUP BY this_.Value, this_1_.OrderNumber 
ORDER BY y1_ asc, y0_ asc

Problem is, if there is more then aproximetly 2000 parameters (not exactly) in “IN” part in “WHERE” part. If less, Its works perfect.

It is NHibernate or SQL Server problem?

What can I do?

Generate more shorter queryes and complete it in C#?

Now I have relativly nice code, if i do it I afraid that it will be a little messy code.

This is code, it is only for illustration. I mean that there is no problem:

public class AdultDAO : ANHibernateDAO<AdultDTO, Nullable<Int32>>, IAdultDAO
    {    
        public ResultQuestinaryDTO Evaluate(
            IEnumerable<LocalityDTO> _Localities,
            IEnumerable<DepartmentDTO> _Departments, 
            bool _IncludeNullDepartment,
            IEnumerable<int> _Months,
            IEnumerable<int> _Years,
            IEnumerable<TypeHospitalization> _Types,
            IEnumerable<Sex> _Sex,
            IEnumerable<int> _Old,
            string _Version)
        {
            // Session
            ISession _Session = NHibernateSessionManager.Instance.GetSession();
            //Criterium
            ICriteria _Criteria = _Session.CreateCriteria(typeof(AdultDTO));

            // Where clause
            _Criteria = _Criteria.Add(Expression.InG("Locality", _Localities.ToArray()));
            _Criteria = _Criteria.Add(Expression.InG("YearHospitalization", _Years.ToArray()));
            _Criteria = _Criteria.Add(Expression.InG("MonthHospitalization", _Months.ToArray()));
            _Criteria = _Criteria.Add(Expression.InG("TypeHospitalization", _Types.ToArray()));
            _Criteria = _Criteria.Add(Expression.InG("Sex", _Sex.ToArray()));
            _Criteria = _Criteria.Add(Expression.InG("Old", _Old.ToArray()));
            _Criteria = _Criteria.Add(Expression.Eq("Version", _Version));

            if ((_Departments.Count() > 0) && (_IncludeNullDepartment))
            {
                _Criteria = _Criteria.Add(Expression.Or(
                    Expression.InG("Department", _Departments.ToArray()),
                    Expression.IsNull("Department")));
            }
            if ((_Departments.Count() > 0))
                _Criteria = _Criteria.Add(Expression.InG("Department", _Departments.ToArray()));
            else
                _Criteria = _Criteria.Add(Expression.IsNull("Department"));

            _Criteria.Add(Expression.Conjunction());
            // Return only id
            _Criteria.SetProjection(Projections.Id());

            // QuestionBoolDTO query
            ICriteria _CriteriaBool = ResultSetHelper.CreateCriteria(
                _Session,
                typeof(QuestionBoolDTO),
                Transformers.AliasToBean<ResultQuestionBoolDTO>(),
                _Criteria.List())
                .AddOrder(new Order("Value", true));

            // QuestionRateDTO query
            ICriteria _CriteriaRate = ResultSetHelper.CreateCriteria(
                _Session,
                typeof(QuestionRateDTO),
                Transformers.AliasToBean<ResultQuestionRateDTO>(),
                _Criteria.List())
                .AddOrder(new Order("Value", true));

            // QuestionSetDTO query
            ICriteria _CriteriaSet = ResultSetHelper.CreateCriteria(
                _Session,
                typeof(QuestionSetDTO),
                Transformers.AliasToBean<ResultQuestionSetDTO>(),
                _Criteria.List());

            // Return result set


            // !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
            // THERE IS CRITICAL PART WHICH THROW EXCEPTION:
            // !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!

            return new ResultQuestinaryDTO
                (
                    _CriteriaRate.List<ResultQuestionRateDTO>(),
                    _CriteriaSet.List<ResultQuestionSetDTO>(),
                    _CriteriaBool.List<ResultQuestionBoolDTO>(),
                    _Criteria.List().Count,
                    AdultDTO.GetTemplate(_Version)
                );
        }


public class ResultQuestinaryDTO
    {
        private IEnumerable<ResultQuestionBoolDTO> _ResultQuestionBool;        
        private IEnumerable<ResultQuestionSetDTO> _ResultQuestionSet;        
        private IEnumerable<ResultQuestionRateDTO> _ResultQuestionRate;                
        private int _CountQuestinary = 0;

        public ResultQuestinaryDTO(
            IEnumerable<ResultQuestionRateDTO> ResultQuestionRate,
            IEnumerable<ResultQuestionSetDTO> ResultQuestionSet,
            IEnumerable<ResultQuestionBoolDTO> ResultQuestionBool,
            int CountQuestinary,
            QuestinaryTemplateWrapper QuestinaryTemplateWrapper
            )
        {
            _ResultQuestionBool = ResultQuestionBool;
            _ResultQuestionRate = ResultQuestionRate;
            _ResultQuestionSet = ResultQuestionSet;
            this.CountQuestinary = CountQuestinary;
            this.QuestinaryTemplateWrapper = QuestinaryTemplateWrapper;
        }
    }
  • 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-20T13:07:42+00:00Added an answer on May 20, 2026 at 1:07 pm

    If you use SQL Server then it limits usage of parameters in SQL. Maximum number of parameters is 2100.

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

Sidebar

Related Questions

a little question. I have this code, which is works perfect for files, but
I have this code, which works fine, but I would like to be able
I have the following code which works just fine when the method is POST,
I have the following code which works fine. However, I only want to return
So far i have got the code below which works lovely when trying an
I have code that looks like the following, which works fine for displaying the
I have made a new windows service which works fine using barebone code (just
I have this live search which works perfect until a company name in my
I have the following code, which will not work. The javascript gives no errors
I have an updatepanel which doesn't work. My whole code: <%@ Page Language=C# MasterPageFile=~/Master.Master

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.