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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 30, 20262026-05-30T04:35:06+00:00 2026-05-30T04:35:06+00:00

I want to pass in a method three parameters. The Classname (table), the field

  • 0

I want to pass in a method three parameters. The Classname (table), the field and the keyword.

Then I would like to take with Entity Framework with reflection the table and find the fields that have the keyword.

Something like

public List<object> FilterOptions(string keyword, string className, string field)
        {
            var objectSet = (System.Data.Objects.ObjectSet<dynamic>)DataContext.GetType().GetProperty(className).GetValue(DataContext, null);
            var options = objectSet.Where(x => x.GetType().GetProperty(field).GetValue(x, null) == keyword).ToList();
...
        }

However I get “An expression tree may not contain a dynamic operation”

When I change <dynamic> to <object> I get an error again.

  • 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-30T04:35:07+00:00Added an answer on May 30, 2026 at 4:35 am

    I think this is where you want to end up. You are wanting field names for your entities?

    there is a property on the ObjectContext class called MetadataWorkspace. You can drill down to an EntitySet which has a property call MetadataProperties. Something like this.

    public List<object> FilterOptions(string keyword, string className, string field)
    {
        return ObjectContext.MetadataWorkspace.GetEntityContainer(context.DefaultContainerName, DataSpace.CSpace).BaseEntitySets.Where(es => es.MetadataProperties.Any(mp => mp.Name == keywork));
        // This has not been tested but should get you on the right path.
    }
    

    see this link.

    Hope this helps.

    P.S. I also would recommend accepting more of your answers. You only have a 33% accept rate. Which means your question will eventually just get passed by. Remember if you found the answer somewhere else you can answer your own question. :0)

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

Sidebar

Related Questions

I want to pass some parameters to my MVC UserControl like ShowTitle(bool) and the
I want to pass a byte[] to a method takes a IntPtr Parameter in
I want to pass a variable to he buttonEvent method in the selector. [button
If I want to pass a structure defined in windows.h to one of method
I want to call a method, pass it the length and have it generate
I want to pass a varying number of parameters between two objects. I have
I want to pass an integer value to a form in .Net so that
I want to pass an int list (List) as a declarative property to a
I want to pass an enum value as command parameter in WPF, using something
I want to pass in the tType of a class to a function, and

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.