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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 13, 20262026-05-13T09:06:45+00:00 2026-05-13T09:06:45+00:00

Embarrassing question really — I have Subsonic collection, then I filter out some data

  • 0

Embarrassing question really — I have Subsonic collection, then I filter out some data using Where.

MyColl.Where(it => it.foo()==true)

now I would like to pass those data still as Subsonic collection. How to do it (the most properly way)? I checked constructor for Subsonic collection, ToX() methods, and googled.

edit: Subsonic 2.x series.

Thank you in advance, and sorry for naive question.

  • 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-13T09:06:45+00:00Added an answer on May 13, 2026 at 9:06 am

    In SubSonic 2.x, the data isn’t actually filtered out with Where() until the query is re-executed against the database. I’m assuming that’s the same in 3.0. In 2.x there was a .Filter() method that would do what you are looking for.

    The .Filter() method gets added to the generated classes. Here’s what mine looks like (it’s customized from the default):

        /// <summary>
        /// Filters an existing collection based on the set criteria. This is an in-memory filter.
        /// All existing wheres are retained.
        /// </summary>
        /// <returns>TblSomethingOrOtherCollection</returns>
        public TblSomethingOrOtherCollection Filter(SubSonic.Where w)
        {
            return Filter(w, false);
        }
    
        /// <summary>
        /// Filters an existing collection based on the set criteria. This is an in-memory filter.
        /// Existing wheres can be cleared if not needed.
        /// </summary>
        /// <returns>TblSomethingOrOtherCollection</returns>
        public TblSomethingOrOtherCollection Filter(SubSonic.Where w, bool clearWheres)
        {
            if (clearWheres)
            {
                this.wheres.Clear();
            }
            this.wheres.Add(w);
            return Filter();
        }
    
        /// <summary>
        /// Filters an existing collection based on the set criteria. This is an in-memory filter.
        /// Thanks to developingchris for this!
        /// </summary>
        /// <returns>TblSomethingOrOtherCollection</returns>
        public TblSomethingOrOtherCollection Filter()
        {
            for (int i = this.Count - 1; i > -1; i--)
            {
                TblSomethingOrOther o = this[i];
                foreach (SubSonic.Where w in this.wheres)
                {
                    bool remove = false;
                    System.Reflection.PropertyInfo pi = o.GetType().GetProperty(w.ColumnName);
                    if (pi != null && pi.CanRead)
                    {
                        object val = pi.GetValue(o, null);
                        if (w.ParameterValue is Array)
                        {
                            Array paramValues = (Array)w.ParameterValue;
                            foreach (object arrayVal in paramValues)
                            {
                                remove = !Utility.IsMatch(w.Comparison, val, arrayVal);
                                if (remove)
                                    break;
                            }
                        }
                        else
                        {
                            remove = !Utility.IsMatch(w.Comparison, val, w.ParameterValue);
                        }
                    }
    
    
                    if (remove)
                    {
                        this.Remove(o);
                        break;
                    }
                }
            }
            return this;
        }
    
    
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Ask A Question

Stats

  • Questions 260k
  • Answers 260k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • Editorial Team
    Editorial Team added an answer Based on some info on PHP.net, will adding this header… May 13, 2026 at 11:29 am
  • Editorial Team
    Editorial Team added an answer In our application we ended up using: DataContractSerializer xs =… May 13, 2026 at 11:29 am
  • Editorial Team
    Editorial Team added an answer I think the answers and notes in my question regarding… May 13, 2026 at 11:29 am

Related Questions

That's it. It's a dumb dumb (embarrassing!) question, but I've never used C# before,
My adventures with entity groups continue after a slightly embarrassing beginning (see Under some
I keep getting tasks that are above my skill level. How can I address this without coming accross as grossly incompetent?
I'm getting an Object does not support this property or method error on the
I set up a hitcounter so that each time someone goes to my site,

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

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.