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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 12, 20262026-05-12T20:19:58+00:00 2026-05-12T20:19:58+00:00

Using LINQ to Entities, how can I determine if any item from a List

  • 0

Using LINQ to Entities, how can I determine if any item from a List of ints exists in a comma delimited string of ints?

For example, I want to write something like the following (logically):

collection.Where(collection.DelimitedStringOfInts.Contains(listOfInts.AnyOfThem))

Also, I should mention that I’m doing this using LINQ method chaining, with the delimited string as part of the entity –

var listOfInts = GetListOfInts();
var query = from x in Db.Items select x;
if (listOfInts != null && listOfInts.Count() > 0)
{
  query = query.Where(x => x.DelimitedStringOfInts.Contains(listOfInts.AnyOfThem));
}

UPDATE:
Using Alex’s referenced article, I implemented a working solution as follows:

var query = from x in Db.Items select x;
var listOfInts = GetListOfInts();
if (listOfInts != null && listOfInts.Any())
{
    //"ToListOfStrings" is a simple extension method I wrote to create a List<string> from a List<int>
    var delimitedIds = listOfInts.ToListOfStrings(','); 
    query = query.Where(
        BuildOrExpression<DatabaseItem, string>(x => x.DelimitedStringOfInts, delimitedIds)
        );
}

An update was required to the “BuildOrExpression” referenced in the article. The “equals” operator had to be changed to a “contains” operator.

var contains = values.Select(value =>
    (Expression)Expression.Call(
                   valueSelector.Body,
                   typeof(string).GetMethod("Contains"),
                   Expression.Constant(
                           value,
                           typeof(TValue)
                   )
           )
   );
  • 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-12T20:19:59+00:00Added an answer on May 12, 2026 at 8:19 pm

    Take a look at this tip, it is not exactly what you are asking for but I think you can tweak it to get what you want.

    Alex

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

Sidebar

Related Questions

How can I convert the string to datetime using linq to entities .... I
I am using Linq to entities and would like to know if I can
I'm using linq to entities(EF). I have a constructor which takes 4 string parameters.
I'm using LINQ-to-Entities. Using the following query: var x = from u in context.Users
I'm using Linq To Entities so I can Linq to my MySql database. My
I wanted to select rows from a view using Linq to Entities, so I
I'm using LINQ to Entities to display paged results. But I'm having issues with
I'm using LINQ to Entities and I want to know how do I translate
I'd like to implement MVC while using LINQ (specifically, LINQ-to-entities). The way I would
Is it worth using System.Transactions.TransactionScope on Linq to Entities? On the MS documentation ,

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.