insert with many to many relationship

Posted by Luca Romagnoli on Stack Overflow See other posts from Stack Overflow or by Luca Romagnoli
Published on 2010-06-09T09:38:36Z Indexed on 2010/06/09 9:42 UTC
Read the original article Hit count: 141

hi, i have 2 object: user, group that have a relationship many to many i want create a user and associate some groups to it. How can i do it?

thanks

I've tried with this. but it's wrong:

user = new User();
List<int> gruppi = new List<int>() {1,2};
utente.Group =db.Group.Where(p => gruppi.Contains(p.GruppoID)

© Stack Overflow or respective owner

Related posts about entity-framework

Related posts about many-to-many