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

The Archive Base Latest Questions

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

I have a good LINQ query that is working well, it returns a result

  • 0

I have a good LINQ query that is working well, it returns a result set, each result set inherits from MyBase.

I need to substitute AbcTransport by doing a kind of loop through of collection of strings I have. These strings are actually the object names (classes)

 MyBase testItem = from x in AbcTransport
                     from y in x.SolidItems
                     where y.Classified == otherObject.Classified 
                     select x;

This will cut down on the amount of code I need to write.

I think this is possible with Dynamic Linq, but I am unsure where to start.

Imagine I have currently about 26 objects like AbcTransport that are all named different but all inherit from MyBase. The property I am interested in is actually on MyBase. If I could do a kind of Loop using Dynamic linq I wouldn’t have to write my query 26 times and also would make in maintainable as when I add more objects I only have to add the object name into my collection and that’s it.

  • 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:26:14+00:00Added an answer on May 24, 2026 at 7:26 pm

    Why not put that query inside a generic method?

    MyBase Get<T>(IEnumerable<T> list) where T : MyBase
    {
        MyBase testItem = from x in list
                          from y in x.SolidItems
                          where y.Classified == otherObject.Classified 
                          select x;
        return testItem;
    }
    

    You could call it like this:

    var result1 = Get(AbcTransport);
    var result2 = Get(DefTransport);
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have the following LINQ query that I need to translate to Entity SQL
I have a query where I need to get post + every tag that
I have LINQ query that is built up in a piecemeal fashion like so:
When using linq and you have c.Sort() Is there any good inline way of
I have good knowledge on the working of a traditional .dll . Also the
(Let's assume that I have good reasons not to remove my NSAssert() checks in
Stackoverflowers, I have a resultset from a SQL query in the form of: Category
We are working on improving our DAL which is written in LINQ that talks
As LINQ is a good query language in dot net and everyone should be
I'm working on a program that needs to be able to load object-properties from

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.