code_junkie

Entity Framework - how do I use the entity relationships in my extended classes?

Nov 13th, 2011
60
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.59 KB | None | 0 0
  1. Public Sub New(ByVal ProjectID As Integer)
  2. Dim proj As Project = (From p In db.Project.Include("Status") Where p.ProjectID = ProjectID).First
  3. _ProjectID = proj.ProjectID
  4. _ProjectName = proj.ProjectName
  5. Me.Status.StatusID = proj.Status.StatusID 'I get errors here
  6. Me.Status.StatusName = proj.Status.StatusName 'and here
  7. End Sub
  8.  
  9. Public Shared Function GetProjectById(ByVal ProjectId as Integer) as Project
  10. Dim db As New MyDataContext
  11. Return (From p In db.Project.Include("Status") Where p.ProjectID = ProjectID).FirstOrDefault
  12. End Function
Add Comment
Please, Sign In to add comment