Hi,

I would like some advice on how to create a class to represent a one to many relationship in C#.

i.e. I have a Customer and an Address table in my database. I also have a Customer class in my C# solution but how do I introduce the multiple address element? Do I have a separate Address class? Do I create a subclass in the Customer class or create a method in Customer called GetAddresses of type List which contains all of the relevant logic?

In my code I need to be able to return a customer with all associated addresses and I just cannot picture the best way to achieve this.

All help greatly appreciated.

Thanks
C

Recommended Answers

All 2 Replies

Thanks - that's great.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.