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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 11, 20262026-05-11T03:26:09+00:00 2026-05-11T03:26:09+00:00

I’m trying to create a linq query based on some dynamic/optional arguments passed into

  • 0

I’m trying to create a linq query based on some dynamic/optional arguments passed into a method.

User [Table] -> zero to many -> Vehicles [Table] User [Table] -> zero to many -> Pets 

So we want all users (including any vechile and/or pet info). Optional filters are

  • Vehicle numberplate
  • Pet name

Because the vehicle and pet tables are zero-to-many, i usually have outer joins between the user table and the vehicle|pet table.

To speed up the query, i was trying to create the dynamic linq and if we have an optional argument provided, redfine the outer join to an inner join.

(The context diagram will have the two tables linked as an outer join by default.)

Can this be done?

I’m also not sure if this SO post can help me, either.

  • 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. 2026-05-11T03:26:09+00:00Added an answer on May 11, 2026 at 3:26 am

    I think you are heading in the wrong direction. You can easily use the fact that LINQ queries are composable here.

    First, you would always use the outer join, and get all users with the appropriate vehicles and pets:

    // Get all the users. IQueryable<User> users = dbContext.Users; 

    Then you would add the filters if necessary:

    // If a filter on the pet name is required, filter. if (!string.IsNullOrEmpty(petNameFilter)) {    // Filter on pet name.    users = users.Where(u => u.Pets.Where(      p => p.Name == petNameFilter).Any()); }  // Add a filter on the license plate number. if (!string.IsNullOrEmpty(licensePlateFilter)) {   // Filter on the license plate.   users = users.Where(     u => u.Cars.Where(c => c.LicensePlace == licensePlateFilter).Any()); } 

    Note that this will not filter out the pets or cars that don’t meet the filter, as it is simply looking for the users that have pets with that name, or cars with that plate.

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

Sidebar

Related Questions

Basically, what I'm trying to create is a page of div tags, each has
link Im having trouble converting the html entites into html characters, (&# 8217;) i
I'm trying to create an if statement in PHP that prevents a single post
I am trying to understand how to use SyndicationItem to display feed which is
I have just tried to save a simple *.rtf file with some websites and
For some reason, after submitting a string like this Jack’s Spindle from a text
I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function
this is what i have right now Drawing an RSS feed into the php,
I am trying to render a haml file in a javascript response like so:
I have a French site that I want to parse, but am running into

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.