c# - Getting a foreign key in a table -


in website, user can add foreignexpressions account. user model looks this:

   [table("userprofile")]    public class userprofile {     [key]     [databasegeneratedattribute(databasegeneratedoption.identity)]     public int userid { get; set; }     public string username { get; set; }      public list<foreignexpression> learnedexpressions { get; set; } } 

then in controller i'd current user's stored expressions this:

db.foreignexpressions.select(f => f.userid == membership.getuser().provideruserkey); 

however, foreignexpression not contain userid field, there's no visible userid f. userprofile has collecion of foreignexpressions, have userid field in foreignexpression table. i'm confused, how supposed foreignexpressions user?

edit:

    public class foreignexpression {     public int id { get; set; }      public string expression { get; set; }     public string context { get; set; }     public string meaning { get; set; }     public datetime dateadded { get; set; }   } 

int userid = membership.getuser().provideruserkey;  db.userprofiles.find(q => q.userid == userid).learnedexpressions.tolist();  

Comments

Popular posts from this blog

java.util.scanner - How to read and add only numbers to array from a text file -

rewrite - Trouble with Wordpress multiple custom querystrings -