views:

55

answers:

1

First off I'm a noob so please be gentle :-) I have a base object Company. I want to inherit this into a Customer object and a Vendor object. My problem starts with the fact that a given company can be a customer and a vendor at the same time. All the examples I have seen a use a property of the company and set it to either customer or vendor, but I can't do this. Any help would be greatly appreciated.

Thanks, Tony

Edit for (I hope) clarity.

stijn

Here is a simplified version of what I am working toward. I have three tables as described below in my db. I have created the model in visual studio and have created associations between the tables (on CompanyId) and tested and everything behaves as expected. When I remove the associations and inherit customer and vendor from company I get lots of errors. My assumptions: Company can be an object or inherited by customer or vendor. A given company can be both a customer and a vendor.

I am very new to entity framework, I started working with it about two weeks back and am still trying to understand the more advanced (for me) parts. Am I completely off base in the direction I am taking, or am I just missing something critical?

Company -ID -Name -Adress -City -etc

Customer -CustomerID -Customer Specific Fields -CompanyID

Vendor -VendorID -Vendor Specific Fields -CompanyID

andrewWinn

In my first try I was able to interact with vendor by creating the object then querying for an instance (right word I think) and using it this Vendor.Company.Address = "123 Happy Trails". What I would like to be able to do instead is Vendor.Address = "123 Happy Trails" using inheritance.

Thanks to both of you guys for trying to help.

A: 

I solved the problem. I was using an existing database. The tables I were trying to use all had auto increment primary keys. They needed to auto increment turned off and 1:1 relationships defined in the database. Once I made these changes I was able to make inheritance behave exactly as I wanted.

T

Tony Heflin