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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 21, 20262026-05-21T05:48:23+00:00 2026-05-21T05:48:23+00:00

I am building an IQueryable based on parameters I get from the user. One

  • 0

I am building an IQueryable based on parameters I get from the user. One of those parameters is a multi-select and I need to retrieve records that contain any of the selected values.

The code that deals with that is:


var ids = parameters.DeliveryID.ToArray();
courses = courses.Where(c => ids.Contains(c.CourseDeliveryID));

In the above code:
1. ids – is a byte array and I make sure it has multiple values before calling Contains().
2. c.CourseDeliveryID – that’s a byte value.

In the database I store CourseDeliveryID as tinyint (SQL Server 2008).

Compilation is just fine.

When I run the code I get the following ArgumentException:

DbExpressionBinding requires an input expression with a collection ResultType.
Parameter name: input

I found the documentation for that exception here:
http://technet.microsoft.com/en-us/library/system.data.common.commandtrees.expressionbuilder.dbexpressionbuilder.bindas.aspx

While trying to solve the problem I found that if I use the same code on shorts, ints or longs I don’t have any problem.

I’m in touch with Microsoft about it since yesterday and will update when I know more, but in the meantime I figured I’d throw it also here to get more advises if possible.

Thanks in advance!

  • 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-21T05:48:23+00:00Added an answer on May 21, 2026 at 5:48 am

    I was able to reproduce your error in LINQPad, and found that using a List<byte> instead of a byte[] would work:

    // byte[] ids = new byte[] { 1, 64 };  <== causes ArgumentException
    List<byte> ids = new List<byte> { 1, 64};
    
    var c = Courses.Where (co => ids.Contains(co.CourseDeliveryId));
    

    will generate the following sql and return results:

    SELECT 
    [Extent1].[CourseId] AS [CourseId], 
    [Extent1].[CourseName] AS [CourseName], 
    [Extent1].[CourseDeliveryId] AS [CourseDeliveryId]
    FROM [dbo].[Courses] AS [Extent1]
    WHERE [Extent1].[CourseDeliveryId] IN (1,64)
    

    It’s also interesting that using an int[] or short[] would also work, producing this sql:

    SELECT 
    [Extent1].[CourseId] AS [CourseId], 
    [Extent1].[CourseName] AS [CourseName], 
    [Extent1].[CourseDeliveryId] AS [CourseDeliveryId]
    FROM [dbo].[Courses] AS [Extent1]
    WHERE (1 =  CAST( [Extent1].[CourseDeliveryId] AS int)) OR (64 =  CAST( [Extent1].[CourseDeliveryId] AS int))
    

    but using a byte[] causes an exception. I can only guess that the SQL Server EF provider is trying to treat byte[] in some special way, resulting in this exception.

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

Sidebar

Related Questions

When building a VS 2008 solution with 19 projects I sometimes get: The GenerateResource
When building static libraries with VS2005 I keep getting linker warnings that VC80.pdb cant
In building an ASP.NET 3.5 WAP, I'm always frustrated by the feeling that no
I'm building an ASP.NET MVC site that uses LINQ to SQL. In my search
Building an application, before using a real database, just to get things work I
I'm building a generic xml repository that uses a datacontractserializer to serialize/deserialize the files
Building on How Do You Express Binary Literals in Python , I was thinking
Building a client-side swing application what should be notified on a bus (application-wide message
Building the same project (without any changes) produces binary different exe-files: some small regions
Building on what has been written in SO question Best Singleton Implementation In Java

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.