none
How to store column values in an entity? RRS feed

  • Question

  • Hi Guys,

    I have defined many to many relationship between 2 entities say for example "USER" and "LIBRARY" and intermediate table is "USERLIBRARY" Now I have fetched the subset of "USERLIBRARY" by a UserId. Is it possible to store all the libraries (from this subset) to a new "LIBRARY" collection? Please tell me how can we achieve it using LINQ?

    Thanks


    Vivek
    • Moved by Andrew.Wu Monday, August 8, 2011 8:46 AM (From:Visual Studio Database Development Tools (Formerly "Database Edition Forum"))
    Saturday, August 6, 2011 10:55 AM

Answers

All replies

  • Hi Vivek,

    Since your question is more related with LINQ, I'm going to help move your post to the dedicated ADO.NET Entity Framework and LINQ to Entities Forum for better support.

    Thanks for your understanding.

    Best Regards,


    Andrew Wu [MSFT]
    MSDN Community Support | Feedback to us
    Get or Request Code Sample from Microsoft
    Please remember to mark the replies as answers if they help and unmark them if they provide no help.

    Monday, August 8, 2011 8:46 AM
  • Hello,

    Regarding one-to-many and many-to-many insertion operation, I suggest you can check the following thread for more information. http://stackoverflow.com/questions/4253165/insert-update-many-to-many-entity-framework-how-do-i-do-it

    The remarkable for this operation (like 1-to-many), you should first initial the collection object and then insert another end of relationship.

    Best Regards,


    Larcolais Gong[MSFT]
    MSDN Community Support | Feedback to us
    Get or Request Code Sample from Microsoft
    Please remember to mark the replies as answers if they help and unmark them if they provide no help.

    • Marked as answer by Larcolais Gong Wednesday, August 17, 2011 5:43 AM
    Monday, August 8, 2011 8:53 AM
  • Hi Vivek;

    I am assuming that you will be using Linq to Entity Framework 4. In answer to your question yes you can query a User table and get all the entries in the Library table for that User and store it locally in a collection.

     


    Fernando (MCSD)

    If a post answers your question, please click "Mark As Answer" on that post and "Mark as Helpful".
    • Marked as answer by Larcolais Gong Wednesday, August 17, 2011 5:43 AM
    Monday, August 8, 2011 3:01 PM