I am working through a tutorial I found on this fourm posted by mendhak in 2008. I am working on the second lesson and for some reason the code to return the number of Article's is always 0. I ran a query and the first two authors should have 2 articles each. is there some reason this does not work?
articleCountLabel.Text = currentAuthor.Article.Count.ToString()
The complete code is at
Tutorial: An Introduction to the ADO.NET Entity Framework [Archive] - VBForums
Here is a short version.
Imports System.Data.Objects
Imports System.Data.Objects.DataClasses
Public Class PayrollView2
Dim publishContext As New PublishingCompanyEntities
Dim authorList As New List(Of Author)
Dim currentAuthorIndex As Integer = 0
Private Sub PayrollView2_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
Dim authorQuery As ObjectQuery(Of Author) = publishContext.Author.Where("it.FirstName <> 'Mark'")
authorList = authorQuery.ToList()
PopulateFields()
End Sub
Private Sub PayrollView2_FormClosed(ByVal sender As System.Object, ByVal e As System.Windows.Forms.FormClosedEventArgs) Handles
MyBase.FormClosed
publishContext.Dispose()
End Sub
Private Sub PopulateFields()
Dim currentAuthor As Author = authorList(currentAuthorIndex)
firstName.Text = currentAuthor.FirstName
lastName.Text = currentAuthor.LastName
authorIDLabel.Text = currentAuthor.AuthorID.ToString()
articleCountLabel.Text = currentAuthor.Article.Count.ToString()
End Sub
articleCountLabel.Text = currentAuthor.Article.Count.ToString()
The complete code is at
Tutorial: An Introduction to the ADO.NET Entity Framework [Archive] - VBForums
Here is a short version.
Imports System.Data.Objects
Imports System.Data.Objects.DataClasses
Public Class PayrollView2
Dim publishContext As New PublishingCompanyEntities
Dim authorList As New List(Of Author)
Dim currentAuthorIndex As Integer = 0
Private Sub PayrollView2_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
Dim authorQuery As ObjectQuery(Of Author) = publishContext.Author.Where("it.FirstName <> 'Mark'")
authorList = authorQuery.ToList()
PopulateFields()
End Sub
Private Sub PayrollView2_FormClosed(ByVal sender As System.Object, ByVal e As System.Windows.Forms.FormClosedEventArgs) Handles
MyBase.FormClosed
publishContext.Dispose()
End Sub
Private Sub PopulateFields()
Dim currentAuthor As Author = authorList(currentAuthorIndex)
firstName.Text = currentAuthor.FirstName
lastName.Text = currentAuthor.LastName
authorIDLabel.Text = currentAuthor.AuthorID.ToString()
articleCountLabel.Text = currentAuthor.Article.Count.ToString()
End Sub