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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 29, 20262026-05-29T10:45:24+00:00 2026-05-29T10:45:24+00:00

In my application, I have Property Setting which is of type String.Collections.Specialized.StringCollection. It contains

  • 0

In my application, I have Property Setting which is of type String.Collections.Specialized.StringCollection. It contains a list of customer codes such as MSFT, SOF, IBM etc. I’m trying to use this in a Linq-to-Entities query in the where clause:

var ShippedOrders = dbcontext.Orders
 .Where(s=>(s.Status.Description.Equals("Shipped") && !Properties.Settings.Default.CustomersToExclude.Contains(s.CustomerCode)));

This fails as Contains is not recognized by Linq-to-Entities with a message similar to:

“LINQ-to-Entities does not recognize the method Contains….”

How do I revise the code above to avoid this error?

  • 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-29T10:45:25+00:00Added an answer on May 29, 2026 at 10:45 am

    Since your question is tagged as C# 4 use a List<string> instead (StringCollection is ancient) and your query should work. Also you should resolve your list reference outside your query:

    List<string> customersToExclude = ..
    var ShippedOrders = dbcontext.Orders
                                 .Where(s=>(s.Status.Description.Equals("Shipped") 
                                        && !customersToExclude.Contains(s.CustomerCode)));
    

    Edit:

    Just copy your customers to an array and use that:

    var customerstoExclude = new string[Properties.Settings.Default.CustomersToExclude.Count];
    myProperties.Settings.Default.CustomersToExclude.CopyTo(customerstoExclude, 0);
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm using the Validation Application Block from Microsoft. I have a string property which
I have a number of enums in my application which are used as property
I have property management application consisting of tables: tenants landlords units properties vendors-contacts Basically
Here is my setup. In my application delegate, I have a property called currentFoo.
I have an MVC application. The model has a property that is a struct
I have a spring-hibernate application which is failing to map an object properly: basically
I have a calculator application in java swing, which is working properly with mouse
In my application I have a tab control which has several tab items. The
I have a windows form application which needs to be the TopMost. I've set
I am writing an application using Core Data which heavily depends on setting attributes

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.