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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 20, 20262026-05-20T13:16:46+00:00 2026-05-20T13:16:46+00:00

I have a datacontext, and it has Authors table. public partial Author:IProductTag{} I want

  • 0

I have a datacontext, and it has Authors table.

public partial Author:IProductTag{}

I want to cast Table<Authors> object to Table<IProductTag>, but that appears to be impossible. I am trying to do that because I want my method to be able to work with different tables which come as input parameters. To be more specific, I need to execute OrderBy and Select methods of the table. I have few other tables, entities of which implement IProductTag . Also, I tried to write a function like:

public static void MyF<t>(){ 
Table<t> t0 = (Table<t>)DataContext.GetMyTableUsingReflection(); 
}

But it fails at compile-time. And if I cast the table to something like ITable or IQueriable, then the OrderBy and Select functions simply don’t work. So how do you deal with 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-20T13:16:47+00:00Added an answer on May 20, 2026 at 1:16 pm

    I suspect you want to make your method generic – so instead of

    void DoSomethingWithTable(Table<IProductTag> table)
    

    you should have

    void DoSomethingWithTable<T>(Table<T> table) where T : class, IProductTag
    

    That should work fine, assuming you only need to read entities (and apply query operators etc). If that doesn’t work for you, please give more details about what your method needs to do.

    (You say that your attempt to use reflection failed, but you haven’t said in what way it failed. Could you give more details?)

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

Sidebar

Related Questions

Suppose I have a UserControl whose DataContext is set to an object that has
I Have a datacontext that has a getuserbyguid method, i want to pass in
I have a situation where I need to access an object that has been
So I have two tables, Table1 and Table2. Table one has an integer that
We have a .Net object that has a static delegate (a data access strategy)
I have a list (see below) contained in a window. The window's DataContext has
I have a custom DataContext with a Table member... Entry is defined as... [Table(Name=Entry)]
I have a LINQ-to-SQL DataContext that represents a parent-child relationship of Products to Prices.
I have a grid bound to a BindingSource which is bound to DataContext table,
Hi I have a mainView window which has its dataContext set to it's own

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.