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?
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:
Thus, this should look like