Hi all,
Here is my tables structure..
Profile: ProfileID (PK), ProfileName varchar(50), GenderID (Fk)
Gender: GenderID (PK), GenderName varchar(50)
Gender table has 2 possible values : Male, Female.
In entity framework, when I am updating the profile with GenderID, I use the following code:
profile.GenderID = Repository.
GetGender(
Request.Form["Profile.GenderName"].ToString()
).GenderID;
Repository.Save();
GetGender method looks like the following:
public Gender GetGender(string genderName)
{
return (from gender in db.Genders
where (gender.GenderName.Equals(genderName))
select gender).First();
}
Is there a better way of doing it? I feel like I am not using Entity Framework like it should be...
If I assign the value to profile.Gender.GenderID as opposed to profile.GenderID then I am updating the original Gender Lookup table which is not what I want.
I am confused..
Thanks..