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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 13, 20262026-05-13T10:41:51+00:00 2026-05-13T10:41:51+00:00

I am trying to run the code in there selected answer but can’t figure

  • 0

I am trying to run the code in there selected answer but can’t figure it out
link text

Here is my code:

using System;
using System.Data;
using System.Data.Objects;
using System.Configuration;
using System.Linq;
using System.Linq.Expressions;
using System.Collections;
using System.Collections.Generic;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Xml.Linq;


namespace System.Linq.IQueryable
{
    static public class LinqExtensions
    {
        public static IQueryable<TEntity> WhereIn<TEntity, TValue>
     (
         this ObjectQuery<TEntity> query,
         Expression<Func<TEntity, TValue>> selector,
         IEnumerable<TValue> collection
     )
        {
            if (selector == null) throw new ArgumentNullException("selector");
            if (collection == null) throw new ArgumentNullException("collection");
            ParameterExpression p = selector.Parameters.Single();

            if (!collection.Any()) return query;

            IEnumerable<Expression> equals = collection.Select(value =>
               (Expression)Expression.Equal(selector.Body,
                    Expression.Constant(value, typeof(TValue))));

            Expression body = equals.Aggregate((accumulate, equal) =>
                Expression.Or(accumulate, equal));

            return query.Where(Expression.Lambda<Func<TEntity, bool>>(body, p));
        }
    }
}

Any ideas

  • 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-13T10:41:52+00:00Added an answer on May 13, 2026 at 10:41 am

    Extensions Methods are tricky in that they are not automatically picked up after you write one. You need either add a using directive or add a reference and then a using directive depending on where you put your extension method.

    This is because extension methods are adding to a class, but not in the traditional way of say a partial class. You are extending the class, however, they are not really object-orientated, so it they require more work on your part before you can consume them, confused yet?

    The following should help:

    using System.Linq.IQueryable
    

    personally I would divide them into a Namespace called “ExtensionMethods”, and then further subdivide them into other Namespaces based on purpose, this will help your sanity.

    There is no limit to the number of Namespaces you can nest, but there is a limit to how many static classes you can nest.

    And in the code that calls it, once you hit the period, you should see it in the auto-complete list.

    I will post an example if you need more help.

    Example:

    Extensions.cs

    using System;
    
    namespace Foo
    {
      namespace Bar
      {
         public static class RangeExtensions
         {
            public static string ToColumnLetter(this int col)
            {
               ... //universal notation for magic :)
            }
         }
      }
    }
    

    Usage.cs

    using System;
    using Foo.Bar;
    
    namespace Foo2
    {
      public class Bar2
      {
         public void ExtensionSample
         {
            Range range = ....
    
            Console.WriteLine(range.Column.ToColumnLetter());
         }
      }
    }
    

    Cheers!

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

Sidebar

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.