How would I best address this object type heirachy? Some kind of enum heirarchy?

Posted by FerretallicA on Stack Overflow See other posts from Stack Overflow or by FerretallicA
Published on 2010-03-24T05:24:32Z Indexed on 2010/03/24 20:43 UTC
Read the original article Hit count: 342

I'm curious as to any solutions out there for addressing object heirarchies in an ORM approach (in this instance, using Entity Framework 4). I'm working through some docs on EF4 and trying to apply it to a simple inventory tracking program. The possible types for inventory to fall into are as follows:

INVENTORY ITEM TYPES:

  • Hardware
    • PC
      • Desktop
      • Server
      • Laptop
    • Accessory
      • Input (keyboards, scanners etc)
      • Output (monitors, printers etc)
      • Storage (USB sticks, tape drives etc)
      • Communication (network cards, routers etc)
  • Software

What recommendations are there for handling enums in a situation like this? Are enums even the solution? I don't really want to have a ridiculously normalised database for such a relatively simple experiment (eg tables for InventoryType, InventorySubtype, InventoryTypeToSubtype etc). I don't really want to over-complicate my data model with each subtype being inherited even though no additional properties or methods are included (except PC types which would ideally have associated accessories and software but that's probably out of scope here).

It feels like there should be a really simple, elegant solution to this but I can't put my finger on it. Any assistance or input appreciated!

© Stack Overflow or respective owner

Related posts about entity-framework

Related posts about .NET