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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T23:40:16+00:00 2026-05-31T23:40:16+00:00

In my code below, is there any way I can use the results in

  • 0

In my code below, is there any way I can use the results in the object ‘WasteRecordsExcluded’ to join with searchResults, essentially excluding the WasteId’s I don’t want.

If I debug to the last line I get the error :

base {System.SystemException} = {“The query contains references to items defined on a different data context.”}

Or if joining is impossible then i could change bHazardous from TRUE to FALSE and FALSE to TRUE and do some kind of ‘NOT IN’ comparison.

Going bananas with this one, anyone help? Kind Regards :

    var allWaste = _securityRepository.FindAllWaste(userId, SystemType.W);
    var allWasteIndicatorItems = _securityRepository.FindAllWasteIndicatorItems();

    // First get all WASTE RECORDS
    var searchResults = (from s in allWaste
                         join x in allWasteIndicatorItems on s.WasteId equals x.WasteId
                         where (s.Description.Contains(searchText)
                         && s.Site.SiteDescription.EndsWith(searchTextSite)
                         && (s.CollectedDate >= startDate && s.CollectedDate <= endDate))
                         && x.EWC.EndsWith(searchTextEWC)
                         select s).Distinct();

    var results = searchResults;



    if (hazardous != "-1")
    {
        // User has requested to filter on Hazardous or Non Hazardous only rather than Show All
        var WasteRecordsExcluded = (from we in _db.WasteIndicatorItems
        .Join(_db.WasteIndicators, wii => wii.WasteIndicatorId, wi => wi.WasteIndicatorId, (wii, wi) => new { wasteid = wii.WasteId, wasteindicatorid = wii.WasteIndicatorId, hazardtypeid = wi.HazardTypeId })
        .Join(_db.HazardTypes, w => w.hazardtypeid, h => h.HazardTypeId, (w, h) => new { wasteid = w.wasteid, hazardous = h.Hazardous })
        .GroupBy(g => new { g.wasteid, g.hazardous })
        .Where(g => g.Key.hazardous == bHazardous && g.Count() >= 1)
          select we);

        // Now join the 2 object to eliminate all the keys that do not apply
        results = results.Where(n => WasteRecordsExcluded.All(t2 => n.WasteId == t2.Key.wasteid));
    }


    return results;
  • 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-31T23:40:17+00:00Added an answer on May 31, 2026 at 11:40 pm

    Maybe something like this:

    .....
    var results = searchResults.ToList();
    .....
    .....
    .Where(g => g.Key.hazardous == bHazardous && g.Count() >= 1)
          select we).ToList();
    .....
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Is there any way I can make the below code work without commenting the
Is there a way to get the code below to return null if no
I have below code to insert a style into DOM (there is a use
For the below code, there ia a form in the location /home/form.php .How can
In the below code instead of specifying the tab name.. Is there anyway we
The code below is resulting in an error on a site in which there
in the code below at first if statements block (there will be more than
The code below is for a simple newsletter signup widget. I'm sure there's a
With the following code below, There is an error saying File /home/user/web_pro/info/views.py, line 184,
Consider the Java code below, what would happen if there were no paintComponent method

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.