none
How to save data to tables at once RRS feed

  • Question

  • Dear all,

    I have the folloing related table structure

    PropertyBasket is containing goods that a customer would like to buy.
    When the user decide to save the basket, he needs to fill up his contact information which will be llinked to his basket content.

    What I am wondering is that, what is the best way to store to my database the basket information and customer data ?

    Should I do it through PropertyBasket.Customer foreign key ?

    if yes how

    thnaks for tips

    regards

    serge


    Your knowledge is enhanced by that of others.

    Wednesday, November 21, 2012 3:56 PM

Answers

  • Hi Serge;

    To your question, "Should I do it through PropertyBasket.Customer foreign key ?", You use the navigation property Customer.

    1. Create a PropertyBasket object and populate its properties.
    2. Create a Customer object and populate its properties.
    3. Assign the Customer object to the PropertyBasket.Customer property
    4. Add the PropertyBasket object to the PropertyBasket DbSet and save the changes.

    // 1 above
    var pb = new PropertyBasket();
    // ... populate properties here
    // 2 above
    var c = new Customer();
    // ... populate Customer here
    pb.Customer = c;


    Fernando (MCSD)

    If a post answers your question, please click "Mark As Answer" on that post and "Mark as Helpful".

    • Marked as answer by Serge Calderara Wednesday, November 21, 2012 11:09 PM
    Wednesday, November 21, 2012 5:25 PM