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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 5, 20262026-06-05T04:42:57+00:00 2026-06-05T04:42:57+00:00

I have a problem in understanding the LINQ to Entites query which does not

  • 0

I have a problem in understanding the LINQ to Entites query which does not give me the desired results. I have the following code, which should execute the deferred query and show the results in Silverlight Datagrid.

  public List<DispIRTSiteReports> DisplayIRTSiteReportsFilOn(List<IssueTypes> issueType, DateTime fDate, DateTime tDate)
  {

  try
        {

            var resultSet = from items in DataContext.IRT_Limited_View
                            select items;

            var iType = issueType.Select(i=>i.IssueName); //contains multiple selected issue type Names

            if (issueType.Count != 0)
            {
                foreach (var type in iType)
                {
                    var copy = type;
                    resultSet = resultSet.Where(items => items.Type_Text.Equals(copy));                       
                }                    
            }

            var newResultSet = (from q in resultSet
                                where q.Date_Time > fDate && q.Date_Time < tDate
                                select new DispIRTSiteReports
                                {                                        
                                    PhExt = q.Phone_Extension,
                                    IssueType = q.Type_Text,
                                    IssueSubType = q.Subtype_Text,
                                    IssueDes = q.Issue_Description
                                }).ToList();

            return newResultSet;

        }
        catch (Exception ex)
        {
            throw ex;
        }

}

I select multiple IssueType Names and they are stored in var iType, but when I execute the code, the resultSet contains null as the first “foreach” iteration alters the resultSet with the first issueType Name and when second iteration is done, the resultSet cannot match the second IssueType Name and thus the resultSet becomes null.

I would like to know how to query the resultSet without altering the original resultSet so that the resultSet contains the corresponding data of multiple IssueType Names selected. Your help in this regard is very much appreciated.

  • 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-05T04:43:00+00:00Added an answer on June 5, 2026 at 4:43 am

    The problem is that you add the predicates, which translates into AND. If you use Contains you get the same semantics as OR:

    resultSet = resultSet.Where(items => iType.Contains(items.Type_Text));
    

    (Note: no foreach loop)

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

Sidebar

Related Questions

I have an understanding problem of how the following code works: XMLInputFactory xif =
I have problem understanding the meaning of join in the following case: Thread t1=new
I have problem understanding the order in which initialization happens. this is the order
I have a problem understanding properties. What kind of property should I write if
I have a problem with understanding the following events, please help. I have an
I have a problem understanding some code fragment from Matlab Signal processing Toolbox fir2()
I'm not sure how to describe this best. But I have a problem understanding
I'm having a problem understanding how to do something in LINQ. I have a
I have a little problem understanding how to to the following in Haskell: Lets
I am newbie to C#, and have a problem with understanding how should I

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.