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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 8, 20262026-06-08T17:22:42+00:00 2026-06-08T17:22:42+00:00

Hi I am trying to achive something like this; Method<TObjectType>(m=>m.GetData); //m is the instance

  • 0

Hi I am trying to achive something like this;

Method<TObjectType>(m=>m.GetData); //m is the instance of TObjectType

if I can succeed on that, then I can visit this expression and get the GetData Method and use it for creating a dynamic sql query. I could do this by giving method name as a string however I don’t want to break the strongly type world of my developer friends.

I know I have to give the exact definition of the delegate but this still doesn’t helped me;

void Method<TObjectType>(Expression<Func<TObjectType, Delegate>> ex){/**/}

Do you have an idea?

  • 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-08T17:22:43+00:00Added an answer on June 8, 2026 at 5:22 pm

    Unfortunately, there’s barely such a thing as “a delegate”. For most purposes (and especially: for resolving a MethodInfo), it must be a strongly-typed delegate. This is because GetData isn’t a method, it is a method group. You really need to specify the method precisely, or have a known delegate-type (which ultimately does the same thing).

    You have two practical options; work to object, or add a generic. For example:

    void Method<TObjectType>(Expression<Func<TObjectType,object>> ex) {...}
    

    would work, as would:

    void Method<TObjectType, TValue>(Expression<Func<TObjectType,TValue>> ex) {...}
    

    The caller would use:

    Method<Foo>(x => x.GetData());
    

    If you really want to use a delegate, the type must be predictable, for example:

    void Method<TObjectType>(Expression<Func<TObjectType,Func<int>>> ex)
    

    allowing:

    Method<Foo>(x => x.GetData);
    

    Alternatively, if you know (for example) that the method is always parameterless, but you don’t know the return type; maybe something like:

    void Method<TObjectType, TValue>(Expression<Func<TObjectType,Func<TValue>>> ex)
    

    which allows:

    Method<Foo, int>(x => x.GetData);
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am trying to achieve something like this. The Expandable List consists of the
I am currently trying to achieve something like this: Based on this class, I
I am trying to achieve exactly something like this - a text view on
What I am trying to achieve is something like this: class object: def __init__(self):
Something like this is what Im trying to achieve: public Attribute<?> getAttribute(Class<? extends Attribute>
I'm trying to achieve something similar to jQuery Glow or this fiddle . Specifically
I fairly new to JQuery and perhaps trying to achieve something that might be
What I have is something similar to this: //method being called by thread pool
I am trying to do something like Facebook's Download Photo link when viewing an
I have a webservice function that returns something like the following: New Orleans, Louisiana

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.