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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 30, 20262026-05-30T20:19:03+00:00 2026-05-30T20:19:03+00:00

I am creating a query, which will have various results depending on the parameters

  • 0

I am creating a query, which will have various results depending on the parameters received and if a situation is met, will create a filter and a set amount of results for this situation. The filter is ready, but do not know how to set the amount in these situations. Below is the query:

public IEnumerable<ConeSlab> ConsultarPlacasAcompanhamento(String codigoLaminador, Int16 placasAEnfornar, Boolean placasEnfornadas, Int16 placasDesenfornadas, Boolean placasRejeitadas)
{
    try
    {               
        var criteria = DetachedCriteria.For<ConeSlab>()
           .CreateAlias("Cone", "C")
           .CreateAlias("Slab.SlabPDO", "SP")
           .Add(Restrictions.Eq("C.Mill", codigoLaminador))
           .Add(Restrictions.IsNotNull("C.IdentBeginDtm"))
           .Add(Restrictions.IsNotNull("SP.IdentBeginDtm"));

        var ordem = "SP.IdentBeginDtm";

        Junction disjunction = Restrictions.Disjunction(); 

        //Identificadas
        if (placasAEnfornar > 0)
        {
            ICriterion criterion = Restrictions.Conjunction()
                .Add(Restrictions.IsNotNull("SP.IdentEndDtm"))
                .Add(Restrictions.IsNull("SP.ChargeDtm"))
                .Add(Restrictions.IsNull("SP.RejectDtm"));
          **//How to set here?**
            disjunction.Add(criterion);
        }

        //Enfornadas
        if (placasEnfornadas)
        {
            ICriterion criterion = Restrictions.Conjunction()
                .Add(Restrictions.IsNotNull("SP.ChargeDtm"))
                .Add(Restrictions.IsNull("SP.DischDtm"))
                .Add(Restrictions.IsNull("SP.RejectDtm"));
            disjunction.Add(criterion); 
        }

        //Desenfornadas
        if (placasDesenfornadas > 0)
        {
            ICriterion criterion = Restrictions.Conjunction()
                .Add(Restrictions.IsNotNull("SP.DischDtm"))
                .Add(Restrictions.IsNull("SP.MillDtm"))
                .Add(Restrictions.IsNull("SP.RejectDtm"));
            **//How to set here?**
            disjunction.Add(criterion); 
       }

        //Rejeitadas
        if (placasRejeitadas)
            criteria.Add(Restrictions.IsNull("SP.RejectDtm"));

        criteria.Add(disjunction); 

        return coneSlabRepository.GetListCriteria(criteria, 300, Order.Desc(ordem));

    }
    catch (Exception ex)
    {
        Log.Error(AppStrings.EventNatureProgramacaoSequenciamento, LibStrings.MessageExceptionQuery, ex);
        throw new LoggedException(ex.Message);
    }
}

How do I set individual returns?

  • 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-30T20:19:05+00:00Added an answer on May 30, 2026 at 8:19 pm

    Define your SetMaxResult in an Int according to the situation and set it to the Criteria before fetching.

       int maxResults = 300;  // Default value.
       var criteria = DetachedCriteria.For<ConeSlab>()
           .CreateAlias("Cone", "C")
           .CreateAlias("Slab.SlabPDO", "SP")
           .Add(Restrictions.Eq("C.Mill", codigoLaminador))
           .Add(Restrictions.IsNotNull("C.IdentBeginDtm"))
           .Add(Restrictions.IsNotNull("SP.IdentBeginDtm"));
    
        Junction disjunction = Restrictions.Disjunction(); 
    
        //Identificadas
        if (placasAEnfornar > 0)
        {
            ICriterion criterion = Restrictions.Conjunction()
                .Add(Restrictions.IsNotNull("SP.IdentEndDtm"))
                .Add(Restrictions.IsNull("SP.ChargeDtm"))
                .Add(Restrictions.IsNull("SP.RejectDtm"));
            disjunction.Add(criterion);
            maxResults = 10; 
        }
    
        //Enfornadas
        if (placasEnfornadas)
        {
            ICriterion criterion = Restrictions.Conjunction()
                .Add(Restrictions.IsNotNull("SP.ChargeDtm"))
                .Add(Restrictions.IsNull("SP.DischDtm"))
                .Add(Restrictions.IsNull("SP.RejectDtm"));
            disjunction.Add(criterion); 
            maxResults = 20;
        }
    
        //Desenfornadas
        if (placasDesenfornadas > 0)
        {
            ICriterion criterion = Restrictions.Conjunction()
                .Add(Restrictions.IsNotNull("SP.DischDtm"))
                .Add(Restrictions.IsNull("SP.MillDtm"))
                .Add(Restrictions.IsNull("SP.RejectDtm"));
            disjunction.Add(criterion); 
            maxResults = 50; 
       }
    
        criteria.Add(disjunction);
        criteria.SetMaxResults(maxResults);
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm creating a query that will display information for a record which is derived
I am creating a program for Android mobiles which will query, retrieve and then
i'm having an issue with creating a query in oracle which doesnt seem to
I have a temp table I am creating a query off of in the
I'm working on creating a SQL query that will pull records from a table
I am working on creating a web app that will query event logs on
I'm creating an ActiveX control that will be used in web pages to query
I am trying to create a Service for my application which will negotiate Bluetooth
I'm creating a php website in which I have a document.php that basically takes
I´m sorry about my stupid question, but I´m stuck. I´m creating application, which will

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.