Q:

Reading related data in Entity framework

I have two tables named StaticPages and StaticPagesContents that these two tables ralated together with StaticSn from StaticPages and StaticID from StaticPagesContents .
I need to read a field from StaticPagesContents named PageContent and display this data on one of my controls so i use this code :
if (DropDownList1.SelectedIndex > -1)
        {
            using (shahedWSEntities myEntity = new shahedWSEntities())
            {
                var content = (from s in myEntity.StaticPages
                               where s.StaticSn == Convert.ToInt32(DropDownList1.SelectedValue)
                               select s);
                if (!object.ReferenceEquals(content, null))
                { 
                    CKEditorControl1.Text=...
                }
            }
        }

but i can't access to StaticPageContents's PageContent field . could you please help me?

A:

Try to do this
var content = (from contents in myEntity.StaticPagesContents
                join sp in myEntity.StaticPages
                on contents.StaticID equals sp.StaticSn 
                           where sp.StaticSn == Convert.ToInt32(DropDownList1.SelectedValue)
                           select contents);

I may have use wrong ID columns but I think this will work for you

