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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 9, 20262026-06-09T22:53:53+00:00 2026-06-09T22:53:53+00:00

I am trying to perform a query using Linq, something I am new to.

  • 0

I am trying to perform a query using Linq, something I am new to.
I would like to receive an array of IDs and retrieve the products with these IDs. The linq query I got to was this one:

    public Product[] RetrieveProduct(int[] ids)
    {
        var query = from productInfos in productRepository.Table
                    where (ids.Contains(productInfos.Id))
                    && productInfos.Active
                    select new ProductIndiInfo
                    {
                        ProductId = productInfos.Id,
                        CurrentPrice = productInfos.CurrentPrice
                    };
        return query.ToArray();
    }

But I keep receiving the famous exception:

{“Unable to create a constant value of type ‘System.Int32[]’. Only
primitive types (‘such as Int32, String, and Guid’) are supported in
this context.”}

Some resources I read say that it is not available. But some others tell me it should work.
I’ve seen many posts with alternatives here and in blogs and so on but it doesn’t work. I am starting to think that this is a syntax issue…

I’ve also tried this approach:

 var query = from productInfos in pricingInfoRepository.Table
                    where ids.Any(id => id == productInfos.ProductId)
                    && productInfos.Active
                    select new PricingInfo
                    {
                        ProductId = productInfos.Id,
                        CurrentPrice = productInfos.CurrentPrice
                    };
        return query.ToArray();

But I got the same issue.

Could someone please tell me if my syntax is wrong or if it is really a Linq problem? (Operation not supported?)

How do I find out which EF version I am using?

Update: As far as I understood, this question about the ids.Contains() would be a L2S question, but a possible answer would be that EF2 does not support it.
Am I understanding it correctly?

  • 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-06-09T22:53:55+00:00Added an answer on June 9, 2026 at 10:53 pm

    Entity Framework only began supporting Contains against arrays in EF 4.0. You can work around this in older versions by building an Expression to include the list of OR conditions.

    ps: how do I find out which EF version I am using?

    Check the version of the System.Data.Entity assembly. Refer to this other question for details.

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

Sidebar

Related Questions

I am trying to perform a query like the following using ActiveRecord and Rails
I`m trying to perform a linq query in a friends JsonArray using Facebook C#
I am trying to perform a LINQ query on a DataTable and show the
I'm trying to perform a DISTINCT clause on a query like this SELECT DISTINCT
I'm trying perform a relatively basic TCP socket send/receive operation on Windows CE using
I'm trying to figure out how to perform a sub-select using Linq. I have
I am trying to perform a regex query using PyMongo against a MongoDB server.
I'm trying to create a query using the LIKE statement. Both examples below work
I'm new at using CoreData and I'm trying to understand how to perform a
I'm trying to perform a linq to entities query on a table that's inherited

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.