I need to get the number of Tasks in a project for the MaxValue property of Telerik ProgressBar and the numbers of completed tasks for its Value property. Below are the codes I used:
Public Sub progressBar() Dim projectID As String = Me.txtID.Text Dim db As New ProjectsEntities() Dim totalTasks = Aggregate task In db.tblTasks Where task.ProjectID = projectID Into Count() Dim totalTasksCompleted = Aggregate task In db.tblTasks Where task.ProjectID = projectID And task.TaskStatus = "Completed" Into Count() Me.TaskProgressBar.Value = totalTasksCompleted Me.TaskProgressBar.MaxValue = totalTasks Me.TaskProgressBar.ChunksCount = totalTasks End Sub
For Average and Sum, below are codes copied from Microsoft Site.
Dim averageOrderCount = Aggregate cust In db.Customers Where cust.City = "London" Into Average(cust.Orders.Count) msg &= "Average number of Orders per customer: " & averageOrderCount & vbCrLf Dim venezuelaTotalOrders = Aggregate cust In db.Customers Where cust.Country = "Venezuela" Into Sum(cust.Orders.Count) msg &= "Total number of orders from Customers in Venezuela: " & venezuelaTotalOrders & vbCrLf MsgBox(msg) Dim averageCustomersByCity = From cust In db.Customers Group By cust.City Into Average(cust.Orders.Count) Order By Average