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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T16:24:48+00:00 2026-05-31T16:24:48+00:00

I am designing an API that is very comparable to Linq (it’s a linq

  • 0

I am designing an API that is very comparable to Linq (it’s a linq that acts on more complex objects) and I have some client developers who don’t quite get the philosophy behind it. I would like to prevent them from doing some things, so that their code is more in line with what the API is all about. So for the examples I will just refer to Linq.

In very short, what I see in the client code is something similar to:

IEnumerable<double> xlist;
IEnumerable<double> ylist;
var zlist = xlist.Select( (x,i) => x + ylist.ElementAt(i) );

This is really bad, and rather than me having to tell people that they are misbehaving, I would like to force my clients to write this instead:

var zlist = xlist.Zip(ylist, (x,y) => x + y);

So after thinking about it, I figured that what I would really want for my API, is to prevent clients from “injecting” data into delegate types. In other words, I would like to define extension methods, such as:

IEnumerable<TResult> MySelect<TSource, TResult>(
                                this IEnumerable<TSource> source,
                                StaticFunc<TSource, int, TResult> selector)

where StaticFunc would be some kind of delegate type that doesn’t hold any data (or at most that would only static-context data).

Can anyone see a way to do that?

  • 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-31T16:24:49+00:00Added an answer on May 31, 2026 at 4:24 pm

    I am designing an API that is very comparable to Linq (it’s a linq that acts on more complex objects) and I have some client developers who don’t quite get the philosophy behind it. I would like to prevent them from doing some things, so that their code is more in line with what the API is all about.

    Sounds like what you’re really in need of is code review and education, rather than tools. There’s certainly nothing within the language to make sure that a developer isn’t doing this – and you wouldn’t even want to, IMO. For example, your rule would prohibit:

    public IQueryable<Person> FindUsersByFirstName(string firstName)
    {
        return repository.Users.Where(user => user.FirstName == firstName);
    }
    

    After all, firstName is contextual data… but that’s perfectly in-keeping with LINQ.

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

Sidebar

Related Questions

I am designing the API for a client of a service that retrieves data
I'm designing a RESTful API that currently has resources that include some elements that
I am designing a game engine that makes use of the DirectX 11 API,
I am designing an API. It will have a lot of methods which do
I am designing RESTful Api's and would like some advice on designing an API
When designing a C API for configuring a library/utility, I have a co-worker who
I'm in the process of designing a .NET API to allow developers to create
I am designing the API for a service that deals with Job entities. I
I am designing a test application (Using NUnit) that will have to navigate (through
I'm designing an API that interacts with MongoDB. Now the question is, if it

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.