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

  • Home
  • SEARCH
  • 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 8048583
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 5, 20262026-06-05T06:29:27+00:00 2026-06-05T06:29:27+00:00

I have a type that wraps an IEnumerable<T> and contains some additional logic, implementing

  • 0

I have a type that wraps an IEnumerable<T> and contains some additional logic, implementing an interface which we’ll call IMyIterable<T>. On one hand, I want people to use LINQ methods to filter and process IMyIterable<T> (by actually applying them to the underlying object), but on the other hand, I still want to fluently expose IMyIterable<T>‘s custom instance functionality (e.g state information) after the LINQ methods have been applied. e.g.

var query = myIterable.Select(x => x.whatever);
//query is now of a completely different type than IMyIterable<T>
var result = query.MyCustomThingy(); 
//But I really want MyCustomThingy to work too.

I know a solution would be:

var query = myIterable.Linq(x => x.Select(y => y.Whatever));

But the extra brackets are unseemly to me. Are there any other ways I could do this? I’m not actually asking for the method Select() to return a custom class (though if there are neat ways to do this, e.g. involving code generation, I’m definitely aboard), just some neater syntax.

  • 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-06-05T06:29:28+00:00Added an answer on June 5, 2026 at 6:29 am

    LINQ is not tied to IEnumerable. You can implement the LINQ methods you need on IMyIterable itself (either as instance methods or as extension methods). This way you can even use the linq syntax directly on a variable of type IMyIterable.

    E.g.:

    public interface IMyIterable<T>
    {
        IMyIterable<TOut> Select<TOut>(Func<T, TOut> selector);
        IMyIterable<T> Where(Func<T, bool> predicate);
        // ...
    }
    

    This would allow you to write something like this:

     IMyIterable<T> source = ...;
    
     var query = from item in source 
                 where item.X == Y
                 select new {...}
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a function that wraps a call to one of my socket types.
Look at this complex type, which is basically a DTO that wraps some entities.
I have a data type that contains a set and a method that expects
I have a Type MenuItem that has one-to-many relationship with itself through Children property.
I have an NSOperation that wraps some web service functionality. The NSOperation has a
I have a C++/CLI project that wraps a native C++ application, which I use
I have a very simple queue implementation that wraps a fixed array. It contains
I have a question. I working on one site on Asp.Net, which uses some
I have this console type thing that accepts a line of C# code, wraps
I have generic type that looks like: public class GenericClass<T, U> where T :

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.