Here is my edmx diagram.
I am trying to use
UserEntity.users.ToList<user>();
This provides me with a complex object of User
s that contain user_groups
, but I can't seem to find the Group
information. My understanding is that EF is supposed to abstract out the join table and provide me with direct access to the Group
information. Please note I am coming from cakephp and hoping for a similar style result!
Edit: Model Code
public static class UserModel
{
static UserEntities dataContext = new UserEntities();
public static void CreateUser(user _newUser)
{
dataContext.users.AddObject(_newUser);
dataContext.SaveChanges();
}
public static List<user> GetAllUsers()
{
return dataContext.users.ToList<user>();
}
}
There is one to many relationship between users
and user_group
, so you may select a single user_group
from users
and against that you will get group.
var result = users.user_group.FirstOrDefault().group;
The Navigation property user_group
in users
will have a collection of user_group
objects, you may select First
or anything based on your requirement and then select group
from there.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.