views:

27

answers:

1

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)
A: 
utente.Group.AddRange(db.Group.Where(p => gruppi.Contains(p.GruppoID))
Craig Stuntz