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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T19:33:11+00:00 2026-05-24T19:33:11+00:00

I have converted the following SQL query to LINQ with the exception of the

  • 0

I have converted the following SQL query to LINQ with the exception of the “NOT IN” subquery.

What would be the most effective way to implement this using LINQ? Should I use a join instead?

If anybody is able to provide an example or some guidance, I’d appreciate it.

New LINQ Query:

     return from objOpenCalls in db.OpenItemss
               from objTasks in db.Tasks
                .Where(t => (t.Task_ID == objOpenCalls.Parent_Task_ID))
                where ((objTasks.Item_ID > 0) && (objTasks.Type_ID > 0) && (objTasks.OwnerTypeItem_ID == user)  && (objOpenCalls.CallEnd < DateTime.Now))
                orderby objOpenCalls.CallStart descending
               select new CallMiniViewModel
               {
                   ID = objOpenCalls.ID,
                   CallStart = objOpenCalls.CallStart,
                   Name = objTasks.Task_Title
               };

Old SQL Query:

SELECT  TOP (100) ta.ID, t.Task_Title, ta.CallStart
FROM         OpenItems AS ta INNER JOIN
                      Tasks AS t ON ta.Parent_Task_ID = t.Task_ID
WHERE   
(t.Item_ID > 0) AND (t.[Type_ID] > 0) AND (ta.CallStart > DATEADD(m, -6, GETDATE())) 
AND (ta.ID NOT IN (SELECT     CallId FROM CallFeedback)) AND (t.OwnerTypeItem_ID = @Username)     AND (ta.CallEnd < GETDATE())
ORDER BY ta.CallStart DESC
  • 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-24T19:33:12+00:00Added an answer on May 24, 2026 at 7:33 pm

    There are a couple of ways of doing the not in. Below is just a quick sample put in LinqPad as a test.

    class MyClass {
        public int Id {get;set;}
    }
    
    void Main()
    {
        int[] myItems = new[] { 1, 2, 3, 4, 5, 6 };
    
        IEnumerable<MyClass> classes = new []{ 
            new MyClass { Id = 3 },
            new MyClass { Id = 6 },
            new MyClass { Id = 8 }
        };
    
        var results = from cl in classes
                        where !myItems.Contains( cl.Id ) 
                        select cl;                                  
    
        foreach(var result in results) {
            Console.WriteLine( "Class {0}", result.Id);
        }
    
        var results2 = from cl in classes
                        where ( 
                            from i in myItems
                            where i == cl.Id
                            select i ).Count( ) == 0 
                        select cl;
    
        foreach(var result in results2) {
            Console.WriteLine( "Class {0}", result.Id);
        }               
    
    }
    

    I normally play with code first in LinqPad as it helps me understand any problems, and it will (if you’re working with SQL) then show you what SQL the query will generate and you can fine tune a little. Sometimes it takes a little time to get your stuff able to be run in there, but it’s worth it with the more complex queries.

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

Sidebar

Related Questions

I have the following query that I would like to convert to LINQ to
I have the following linq to sql query: DateTime linqdate = (from de in
I have following SQL query and I want to convert it to LINQ. I
I have the following query in SQL which I would like to convert to
Have the following (non-straightforward) T-SQL query, which i'm trying to convert to LINQ (to
I have the following query that needs to be converted from Oracel PL/SQL to
I have the following SQL query: SELECT C.ID, C.Name FROM Category C JOIN Layout
I have the following in linq-to-entities clientprojects = (from p in this.SAPMappingEntities.SAP_Master_Projects join c
Hi guys I have this SQL query (MSSQL), I'm doing a query where the
I have following sql query for finding 2nd max salary. Select * From Employee

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.