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

The Archive Base Latest Questions

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

I am attempting to convert a SQL stored procedure to LINQ to do some

  • 0

I am attempting to convert a SQL stored procedure to LINQ to do some performance testing (trying to figure out if using LINQ in some of our methods will speed things up at all)

I am fairly new to doing anything in LINQ so I am just modifying examples in books / online to suit my needs and am stuck on something.

I have this code so far:

DIM TicketID as INTEGER = 1

DIM s = 
FROM User in PersonnelTbl 
WHERE !(from t in tblSupportTicketNotifications where t.TicketID = TicketID select t.EmployeeID).Contains(User.EmployeeID)
Select user

Im not sure why but I get an Identifier expected error message on the Where clause line. Can anyone point me in the right direction? Cheers

I’ve based my code so far on this example:

var query = 

    from c in dc.Customers 

    where !(from o in dc.Orders 

            select o.CustomerID)

           .Contains(c.CustomerID) 

    select c;

This is what I am trying to convert

CREATE PROCEDURE spGetEmployeesToBeNotified  
(  
 @TicketID INT  
)  
AS   
BEGIN  

 SELECT   
  ID,   
  FirstName,  
  Surname,  
  FirstName+' '+Surname As FullName,   
  WorkEmail,   
  0 AS Checked  
 FROM   
  PersonnelTbl   
 WHERE   
  ID NOT IN(SELECT EmployeeID FROM tblSupportTicketNotifications WHERE TicketID = @TicketID)  
 AND  
  (FirstName IS NOT NULL   
  AND   
   FirstName <> ''   
  AND   
   Surname IS NOT NULL   
  AND   
   Surname <> '')  

 UNION  
 SELECT   
  person.ID,  
  person.FirstName,  
  person.Surname,  
  person.FirstName +' '+person.Surname As FullName,  
  person.WorkEmail,  
  1 AS Checked  
 FROM  
  PersonnelTbl person  
 JOIN  
  tblSupportTicketNotifications notify  
 ON  
  person.ID = notify.EmployeeID  
 WHERE  
  TicketID = @TicketID  
 ORDER BY   
  FirstName ASC,   
  Surname ASC  
END
  • 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-26T10:24:16+00:00Added an answer on May 26, 2026 at 10:24 am

    Assuming you have an association between User and SupportTicketNotifications, you could try the following which should use an Exists clause rather than In. You can then profile the differences in SQL to see which one actually works faster (or if the SQL engine optimizes them to the same things.)

    DIM TicketID as INTEGER = 1 
    
    DIM s =  
    FROM User in PersonnelTbl  
    WHERE Not User.SupportTicketNotifications.Any(Function(t) t.TicketID = TicketID)
    
    ' The Select is optional in VB if you are just returning the item you are selecting.
    

    Regarding performance with LINQ to SQL as compared to raw ADO, you may want to check out http://blogs.msdn.com/ricom/archive/2007/06/22/dlinq-linq-to-sql-performance-part-1.aspx. As you are learning LINQ, you should make an effort to profile what you are doing in any regard to help you learn what’s happening and where you need to make performance improvements (including using Stored Procs/custom ADO where necessary).

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

Sidebar

Related Questions

Is there an easy way to convert Transact-SQL to MySQL? I am attempting to
I'm attempting to convert some VBScript to javascript, but I doubt it's possible because
I'm attempting to convert a Python application I coded using the cmd module into
I have data stored in a SQL database that I'm attempting to read into
I'm attempting to convert a JSON object to a normal object using the following...
I am trying to store some objects in an SQL Server Compact (SQL CE)
I'm attempting to convert some of my code from Tkinter to wxPython. Currently I'm
I'm attempting to convert a PDF to a JPEG using ImageMagick. The PDF: baby_aRCWTU.pdf
I'm attempting to convert a C header into a Python library using ctypes and
I'm attempting to use the XML::Simple CPAN module to convert output from our database

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.