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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 16, 20262026-05-16T23:30:06+00:00 2026-05-16T23:30:06+00:00

I have a manager class with a number of sub-classes. I find one particular

  • 0

I have a “manager” class with a number of sub-classes. I find one particular method being duplicated in all or almost all of the sub-classes, so I want to generalize it. In one case, it looks like this:

                        var Results =
                        from j in Job.All( )
                        where guids.Contains( j.JobID )
                        orderby j.JobNumber
                        select j;

I am using SubSonic, so Job.All( ) is a static method that returns an IQueryable<Job>. guids is an IEnumerable<Guid> which holds a list of keys into the Job table. My final result is a SQL query with WHERE Job.JobID IN (x, y, z).

What I’m looking for is a way to call a method like this where I pass in guids, “Job”, “JobID” and “JobNumber” so that I can plug them into the appropriate places.

There is a limit to the number of parameters a SQL IN clause can handle, so my general method would also check guids.Count and code a little bit different query when it exceeded a certain number (say, 2000). This code is also in all the sub-classes.

Note: I have no objection to using the lambda-style notation. This is my first cut, which has problems with “T.All( )”, and item.???:

    const int MAX_ITEMS = 2000;
    public List<T> GetFromList<T>( List<Guid> _IDs ) 
        where T : class, IActiveRecord
    {
        List<T> rc;
        if ( MAX_ITEMS > _IDs.Count )
        {
            var Results =
                from item in T.All( )
                where _IDs.Contains( item.??? )
                orderby item.???
                select item;
            rc = Results.ToList<T>( );
        }
        else // too many for IN clause
        {
            var Results =
                from id in _IDs
                join item in T.All( ) on id equals item.???
                orderby item.???
                select item;
            rc = Results.ToList<T>( );
        }
        return rc;
    }
  • 1 1 Answer
  • 1 View
  • 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-16T23:30:06+00:00Added an answer on May 16, 2026 at 11:30 pm
    const int MAX_ITEMS = 2000; 
    public List<T> GetFromList<T>( List<Guid> _IDs, T _db, 
                  Expression<Func<T, Guid>> GetID, 
                  Expression<Func<IQueryable<T>> GetAll  )  
        where T : class, IActiveRecord 
    { 
        List<T> rc; 
        if ( MAX_ITEMS > _IDs.Count ) 
        { 
            var Results = 
                from item in GetAll( ) 
                where _IDs.Contains( GetID(item)) 
                orderby GetID(item) 
                select item; 
            rc = Results.ToList<T>( ); 
        } 
        else // too many for IN clause 
        { 
            var Results = 
                from id in _IDs 
                join item in T.All( ) on id equals GetID(item) 
                orderby GetID(item)
                select item; 
            rc = Results.ToList<T>( ); 
        } 
        return rc; 
    }
    

    called by:

         GetFromList(ids, db, item=>item.JobID, ()=> Job.All());
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a simple update method in my manager class and I need to
Possible Duplicate: C/C++ line number Hi, I have a simple error manager class that
I have a class that is a manager sort of class. One of it's
I have a Manager class and also one frame which isReport .In the frame
I have a manager class, which update json data from web, get values... The
I have an sqlConnection manager class like so: public class SQLConn { public string
I have a class Manager and a class Base (with subclasses deriving from Base,
I have the following manager<->worker situation: class Manager { private: pthread_attr_t workerSettings; pthread_t worker;
I have the following: MODEL.PY LIST = (('Manager', 'Manager'),('Non-Manager', 'Non-Manager'),) class Employee(models.Model): fname =
In my game I have a concept of resource manager, a class that stores

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.