none
From table relation to List type RRS feed

  • Question

  • Hi all! :) I'm making a simple SQL Server DB, and porting all tables to C# classes through Visual Studio's "LINQ to SQL classes" procedure. I have a Customer class (based on Customers table) associated to a PhoneNumber class (based on PhoneNumbers table), because a Customer can have one or more PhoneNumbers, and each PhoneNumber belongs to one Customer. Is it possible to use a List<PhoneNumber> property for Customer class, instead of having to search in PhoneNumber class for querying Customers' PhoneNumbers? I hope I've been clear, if not then I'll try to explain better. :) Thank you for your help!
    • Moved by Leo Liu - MSFT Monday, February 28, 2011 8:17 AM Off-topic, moved for better support. (From:Visual C# General)
    Friday, February 25, 2011 2:28 PM

Answers

  • I kind of get what you want and the answer is yes, you can but I'm not totally sure you should.  If you are worried about too many calls to the db, you shouldn't, linq caches the data so, only if the data has changed a new request to the db will be made, so you can store the phonenumber table as a list with the associated customer record.

    Regards

    Friday, February 25, 2011 3:28 PM