Hey,
I'm new to linq and I'm trying to write an update statement.
I have two tables, tblProject and tblPage. the two are linked via a foreign key in tblPage.
So when trying to create a row in tblPage this it th inq query I have
public void CreatePage(int projectId, string pageName, DateTime createdDate, int createdBy, DateTime updatedDate, int updatedBy)
{
using (EverythingEngineEntities db = new EverythingEngineEntities())
{
Page page = new Page();
page.Project = db.ProjectSet.Single(p => p.ProjectId == projectId);
page.LastUpdatedBy = updatedBy;
page.LastUpdatedDate = updatedDate;
page.CreatedBy = createdBy;
page.CreatedDate = createdDate;
page.PageName = pageName;
}
}
What I want to know is this the correct way of inserting a row via linq to Entities.
Sorry if none of this makes sense :)
Edit:
I'm particulary interested if this line is the correct way
page.Project = db.ProjectSet.Single(p => p.ProjectId == projectId);