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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T23:54:36+00:00 2026-05-26T23:54:36+00:00

Any way to make this less verbose? var model = ( from MvrTable in

  • 0

Any way to make this less verbose?

var model =
(
    from MvrTable in
    LinqEntitiesCtx.Mvrs

    join MvrMedsTable in LinqEntitiesCtx.MvrMeds
    .Where(Id => Id.FKMvrId == 1)//inner join will be fast with this!

    on MvrTable.PKMvrId equals MvrMedsTable.FKMvrId

    join MvrLocationTable in LinqEntitiesCtx.MvrLocations
    on MvrTable.PKMvrId equals MvrLocationTable.FKMvrId

    join MvrEmployeeTable in LinqEntitiesCtx.MvrEmployees
    on MvrTable.PKMvrId equals MvrEmployeeTable.FKMvrId

    //notice i am using a different primary key that previouslly
    join MvrMedsAdminRouteTable in LinqEntitiesCtx.MvrMedsAdminRoutes
    on MvrMedsTable.PKMvrMedsId equals MvrMedsAdminRouteTable.FKMvrMedsId

    select new
    { //here I choose the columns I want to display
       MvrTable.PKMvrId,
       MvrTable.VarianceDescription,
       MvrTable.CaseNumber,
       MvrTable.DateOfReport,
       MvrTable.DateOfVariance
    }
);

Equivalent SQL code of above:

SELECT [t0].[PKMvrId], [t0].[VarianceDescription], [t0].[CaseNumber], [t0].[DateOfReport], [t0].[DateOfVariance], [t1].[PKMvrMedsId]
FROM [Mvrs] AS [t0]
INNER JOIN [MvrMeds] AS [t1] ON ([t0].[PKMvrId]) = [t1].[FKMvrId]
INNER JOIN [MvrLocations] AS [t2] ON ([t0].[PKMvrId]) = [t2].[FKMvrId]
INNER JOIN [MvrEmployees] AS [t3] ON [t0].[PKMvrId] = [t3].[FKMvrId]
INNER JOIN [MvrMedsAdminRoutes] AS [t4] ON ([t1].[PKMvrMedsId]) = [t4].[FKMvrMedsId]
WHERE [t1].[FKMvrId] =ParamMvrId
  • 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-26T23:54:37+00:00Added an answer on May 26, 2026 at 11:54 pm

    By using Associations it could probably be written more compact. Something like (not complete):

    var model =  from MvrTable in LinqEntitiesCtx.Mvrs
                 where MvrTable.MvrMeds.MvrLocations.Any() //These are the Associations
                 select new
                 {
                   MvrTable.PKMvrId,
                   MvrTable.VarianceDescription,
                   MvrTable.CaseNumber,
                   MvrTable.DateOfReport,
                   MvrTable.DateOfVariance
                 };
    

    You don’y really need the joins since you are not getting any data from those tables. You should use Any instead which corresponds to SQL’s EXISTS.

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

Sidebar

Related Questions

Is there any way to make this work in Java? public static void change(List<?
MyClass c = 10; Is there any way to make this code work? I
Is there any better way to make this query work? I'm looking for a
Any way to make a OS X Finder like but valid XHTML/CSS search textfield
Is there any way to make Visual Studio 2008 Express store all the files
Is there any way to make Visual Studio word-wrap at 80 characters? I'm using
Is there any way to make a function (the ones I'm thinking of are
is there any way to make IE6 understand double classes, say I have a
Is there any way to make Visual Studio show the code of a control
Is there any way to make sure that a table and cells it contains

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.