2

I have set up a view on a legacy table containing order items. In my program, I want to distinguish between phone orders, wifi orders, internet orders, and miscellaneous orders. The legacy table doesn't have a discriminator column, however, you can group the orders by their product code string. Is there a way of creating a table-per-hierarchy from this design?

Example:

  • Phone codes: 30000-01, 30000-02, 30000-05, ...
  • Wifi codes: 30000-17, 30000-52, ...
  • etc.

Edit: I still need an order view showing all of these orders for the department listed as well.

Jamie Lester
  • 848
  • 9
  • 20

1 Answers1

1

You can create a View per type:

create view PhoneOrders as
select *
from orders
where code in ('30000-01', '30000-02',...

EF should be OK with these, as read-only anyway.

simon at rcl
  • 7,326
  • 1
  • 17
  • 24
  • Thank you for the help! I also need an order view with all the orders on it. That's why I was thinking of going the table per hierarchy route. The order view already has a where condition similar to that but with all of the product codes. Will this solution still work? – Jamie Lester Mar 14 '14 at 17:08
  • Should do, if I understand what you're asking. – simon at rcl Mar 14 '14 at 17:13
  • So I would just have an a PhoneOrder, a WifiOrder, an InternetOrder, and a MiscOrder view, plus an Order view that contains everything in the other views. – Jamie Lester Mar 14 '14 at 17:23
  • If that;s what you need, yes! – simon at rcl Mar 14 '14 at 17:27