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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 14, 20262026-05-14T14:55:35+00:00 2026-05-14T14:55:35+00:00

I need to convert the below Sproc to a Linq query. At the very

  • 0

I need to convert the below Sproc to a Linq query. At the very bottom is what I have so far. For reference the fields behind the “splat”(not my sproc) are

ImmunizationID int, HAReviewID int, ImmunizationMaintID int, ImmunizationOther varchar(50), ImmunizationDate smalldatetime, ImmunizationReasonID int

The first two are PK and FK, respectively. The other two ints are linke to the Maint Table where there description is stored. That is what I am stuck on, the INNER JOIN AND the LEFT OUTER JOIN

Thanks,

SELECT tblHAReviewImmunizations.*, 
       tblMaintItem.ItemDescription, 
       tblMaintItem2.ItemDescription as Reason
FROM 
       dbo.tblHAReviewImmunizations 
       INNER JOIN dbo.tblMaintItem 
            ON dbo.tblHAReviewImmunizations.ImmunizationMaintID =
                dbo.tblMaintItem.ItemID 
        LEFT OUTER JOIN dbo.tblMaintItem as tblMaintItem2 
            ON dbo.tblHAReviewImmunizations.ImmunizationReasonID =
                tblMaintItem2.ItemID 
WHERE
       HAReviewID = @haReviewID

My attempt so far –>

public static DataTable GetImmunizations(int haReviewID)
{
    using (var context = McpDataContext.Create())
    {
        var currentImmunizations =
            from haReviewImmunization in context.tblHAReviewImmunizations
            where haReviewImmunization.HAReviewID == haReviewID
            join maintItem in context.tblMaintItems
                on haReviewImmunization.ImmunizationReasonID 
                equals maintItem.ItemID into g
            from maintItem in g.DefaultIfEmpty() 
            let Immunization = GetImmunizationNameByID(
                haReviewImmunization.ImmunizationMaintID)
            select new
            {
                haReviewImmunization.ImmunizationDate,
                haReviewImmunization.ImmunizationOther,
                Immunization,
                Reason = maintItem == null ? " " : maintItem.ItemDescription
            };

        return currentImmunizations.CopyLinqToDataTable();
    }
}

private static string GetImmunizationNameByID(int? immunizationID)
{
    using (var context = McpDataContext.Create())
    {
        var domainName =
            from maintItem in context.tblMaintItems
            where maintItem.ItemID == immunizationID
            select maintItem.ItemDescription;

        return domainName.SingleOrDefault();
    }
}
  • 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-14T14:55:36+00:00Added an answer on May 14, 2026 at 2:55 pm
    public static DataTable GetImmunizations(int haReviewID)
    {
        using (var context = McpDataContext.Create())
        {
            var currentImmunizations =
                from haReviewImmunization in context.tblHAReviewImmunizations
                where haReviewImmunization.HAReviewID == haReviewID
    
                join maintItem in context.tblMaintItems
                on haReviewImmunization.ImmunizationMaintID 
                equals maintItem.ItemID
    
                join maintItem2 in context.tblMaintItems
                on haReviewImmunization.ImmunizationReasonID 
                equals maintItem2.ItemID into g
                from maintItem3 in g.DefaultIfEmpty()
    
                select new
                {
                    haReviewImmunization.ImmunizationDate,
                    haReviewImmunization.ImmunizationOther,
                    maintItem.ItemDescription,
                    Reason = maintItem3 == null ? " " : maintItem3.ItemDescription
                };
    
            return currentImmunizations.CopyLinqToDataTable();
        }
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a SQL Server query that I need to convert to MySQL. I've
I have some C++ code (segment seen below), I need to convert this to
Given a string as below, I need to convert: 1 Dec 2008 06:43:00 +0100
I am a little new to this, but I need to convert the below
I need to convert some VBScript code to C# 2.0, below is the VBScript
i need Sql query Convert Table1 to Table2 select Count(Page) as VisitingCount,CONVERT(VARCHAR(5),Date, 108) as
Hi I have a scenario where I need to convert the default Charset should
I have this dilemma with JavaScript. I need to convert a list of dates
I need to convert an object to xml and have gone through few articles
I have below code. I want to convert this as cross browser compatible. As

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.