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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 29, 20262026-05-29T09:50:44+00:00 2026-05-29T09:50:44+00:00

I asked the question this way because I can imagine that there’s a potentially

  • 0

I asked the question this way because I can imagine that there’s a potentially easy but Devart specific solution, but maybe also a very general solution for any similar situation.

I’m using Devart LINQ To Oracle, and generally you create a class like ItemX in the lqml file at design time and specify what table is behind it. Then, at run time, you use a Table(Of ItemX) to query the database. So far so good.

Now I’ve got a situation where I have two identical tables, ItemX and ItemY, and I need to query from one or the other depending on a runtime flag. Other than this, all code is identical and I want to keep it that way. However, the Table(Of ItemX) is strongly typed, and so I would need to have duplicate versions of everything, with the only difference being the data type.

So, the Devart specific solution would be: have one item class called, just, Item, but at runtime do something so that the Devart DataContext uses a different backing table. Then all code uses the base Item object, but when persisting to and from the database, it knows which table to use. Is there any way to do this?

The more general approach would be some way of hooking into the IQueryable chain so that it used the ItemX and ItemY classes internally, but transformed everything to the base Item class in the external signatures. I can’t even picture this clearly enough to phrase the question though. Is there any way to accomplish this?

  • 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-29T09:50:45+00:00Added an answer on May 29, 2026 at 9:50 am

    You can implement this scenario by manually creating a base class (which is not mapped to any table) and two its ‘trivial’ descendants (each mapped to one of the tables you work with).

    More precisely, the following steps should be performed:

    • generate a model with an entity class corresponding to either of the tables;
    • move this entity class from the generated code somewhere else;
    • remove the Table attribute from this class;
    • (optionally) rename the class to, e.g., ‘ItemBase’;
    • declare two public descendants of this class (e.g., ‘ItemX’ and ‘ItemY’);
    • set the Table attribute pointing to the proper table on each of these descendants;
    • remove the ‘ItemBases’ property (the one returning a Devart.Data.Linq.Table object; of course, it may have some other name) of your DataContext class and add analogous properties returning Table and Table instead.

    Thus, this should look like

    namespace MyContext {
    
      public partial class ItemBase : INotifyPropertyChanging, INotifyPropertyChanged {
        ... // Generated code.
      }
    
      [Table(Name = @"ItemXs")]
      public partial class ItemX : ItemBase {}
    
      [Table(Name = @"ItemYs")]
      public partial class ItemY : ItemBase {}
    
      public partial class MyDataContext {
    
        public Devart.Data.Linq.Table<ItemX > ItemXs {
          get { return this.GetTable<ItemX>(); }
        }
    
        public Devart.Data.Linq.Table<ItemY> ItemYs {
          get { return this.GetTable<ItemY>(); }
        }
      }
    
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I know that this question has been asked many times ( but in different
This question has been asked few times here and there, but you see all
I asked a similar question about this previously, but I did not specify that
This question seems to get asked a lot, but I can't find an answer
I believe this questions has been asked in some or the other way but
I asked this question over Security site, and people there suggested I should have
I asked this question earlier: How to get delta between two text items But
I asked this question earlier. I am intrigued by std::set but I have another
I asked this question earlier and it was closed because it was a duplicate,
I usually see this question asked the other way, such as Must every ivar

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.