Convert anonymous type to strong type for grouping query? - vb.net

I've pieced together some information from other posts but I'm stuck.
The first part works fine. Basically I query the database using LINQ and then I loop through the results generating a report.
Dim results As System.Linq.IQueryable(Of Bud900Reports.tblBud_CONNECT)
If options.Type = reportType.Organization Then
results = From p In db.tblBud_CONNECTs _
Where p.TableOldName = "tblFY" & options.FiscalYear And p.DEPTID = options.GroupFilter _
Order By p.SOURCE_CODE, p.ROW_CODE_903 _
Select p
ElseIf options.Type = reportType.Division Then
'Here is my problem line
End If
For each result in results
'loop through code generating report
Next
Now instead of having three function with alot of dupelicate code, if the reportType is Division I want to run this query and put it into the results set.
results = (From p In db.tblBud_CONNECTs _
Where p.TableOldName = "tblFY" & options.FiscalYear And p.DIVISION_CODE = options.GroupFilter _
Group p By p.DIVISION_CODE, p.SOURCE_CODE, p.ROW_CODE_903 Into _
OrigEft = Sum(p.OrigEft), OrigAmt = Sum(p.OrigAmt), ABEft = Sum(p.ABEft), ABAmt = Sum(p.ABAmt) _
Order By DIVISION_CODE, SOURCE_CODE, ROW_CODE_903 _
Select DIVISION_CODE, SOURCE_CODE, ROW_CODE_903, OrigEft, OrigAmt, ABEft, ABAmt)
It's the same data just grouped and summed up. But it comes through as an anonymous type. I tried to do "select new tblBud_CONNECTs with {.DIVISION_CODE = DIVISION_CODE, ...}" but it gave me the error of "Explicit construction of entity type tblBud_CONNECTs is not allowed".
How can I do what I want? It seems that I should be able to. Thanks.

For completeness I'll answer my own question.
First I created a class to hold the results.
Private Class results
Private mDivCode As String
Public Property DivCode() As String
Get
Return mDivCode
End Get
Set(ByVal value As String)
mDivCode = value
End Set
End Property
Private mSourceCode As Short
Public Property SourceCode() As Short
Get
Return mSourceCode
End Get
Set(ByVal value As Short)
mSourceCode = value
End Set
End Property
Private mRowCode As Short
Public Property RowCode() As Short
Get
Return mRowCode
End Get
Set(ByVal value As Short)
mRowCode = value
End Set
End Property
Private mOrigEft As Decimal
Public Property OrigEft() As Decimal
Get
Return mOrigEft
End Get
Set(ByVal value As Decimal)
mOrigEft = value
End Set
End Property
Private mOrigAmt As Decimal
Public Property OrigAmt() As Decimal
Get
Return mOrigAmt
End Get
Set(ByVal value As Decimal)
mOrigAmt = value
End Set
End Property
Private mABEft As Decimal
Public Property ABEft() As Decimal
Get
Return mABEft
End Get
Set(ByVal value As Decimal)
mABEft = value
End Set
End Property
Private mABAmt As Decimal
Public Property ABAmt() As Decimal
Get
Return mABAmt
End Get
Set(ByVal value As Decimal)
mABAmt = value
End Set
End Property
End Class
Then I set a variable to hold the results.
Dim results As System.Linq.IQueryable(Of results)
Then I made my linq query fill up the results like so.
results = (From p In db.tblBud_CONNECTs _
Where p.TableOldName = "tblFY" & options.FiscalYear And p.DEPTID = options.GroupFilter _
Order By p.SOURCE_CODE, p.ROW_CODE_903 _
Select New results With {.DivCode = p.DIVISION_CODE, .SourceCode = p.SOURCE_CODE.Value, .RowCode = p.ROW_CODE_903.Value, _
.OrigEft = p.OrigEft.Value, .OrigAmt = p.OrigAmt.Value, .ABEft = p.ABEft.Value, .ABAmt = p.ABAmt.Value})
That's how I ended up doing what I wanted.

The solution is to create a collection of the Division instances and populate this collection using 'results'.
Then you can use the Attach method to enable change tracking for these entities.

Related

How to convert a list of different data types into string in vb.net

I created a list using a class which has different data types. It is populated as follows:
[1/16/2015 10:30:14 PM] 241.167.2.72:5
[1/17/2015 11:30:06 PM] 100.133.2.55:6
[1/18/2015 12:30:33 PM] 206.140.3.10:7
Now I just want to display this in a textbox on a page. But get this:
ClientWebApp.DedicatedServerApi.Formatted_DDoS_SampleFlows
ClientWebApp.DedicatedServerApi.Formatted_DDoS_SampleFlows
ClientWebApp.DedicatedServerApi.Formatted_DDoS_SampleFlows
I'm using this line of code with the ToString()...but obviously it is not correct.
strSampleFlowLine = formattedDDoSSampleFlow.ToString() & vbCrLf & vbCrLf
Any Ideas?
The code (and classes) that attempts to populate the text box on the page:
Dim ddosDetailsInfoResult As New DedicatedServerApi.DDoSDetailsInfoResult
Dim formattedDDoSSampleFlow As New DedicatedServerApi.Formatted_DDoS_SampleFlows
' Create a list field - an array of the DDoS sample flows.
Dim formattedDDoSSampleFlowsList As New List(Of DedicatedServerApi.Formatted_DDoS_SampleFlows)
If ddosDetailsInfoResult.DDoS_Details.Formattted_DDoS_SampleFlows_List.Count > 0 Then
' Note: had to add .ToList() as it was giving a syntax error: cannot be converted to a 1-dimensional array.
' Does not make sense as the "Formattted_DDoS_SampleFlows_List" variable is defined exactly like the receiving field.
formattedDDoSSampleFlowsList = ddosDetailsInfoResult.DDoS_Details.Formattted_DDoS_SampleFlows_List.ToList()
For Each formattedDDoSSampleFlow In formattedDDoSSampleFlowsList
' Example of entry in the list: [1/16/2015 10:30:14 PM] 241.167.2.72:5
strSampleFlowLine = formattedDDoSSampleFlow.ToString() & vbCrLf & vbCrLf
' Build the sample flow list textbox.
txtGDHDApiSampleFlowList.Text = txtGDHDApiSampleFlowList.Text & strSampleFlowLine
Next
Else
'An empty list.
txtGDHDApiSampleFlowList.Text = ""
End If
'+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
' Holds formatted DDoS sample flows settings.
' [1/16/2015 10:30:14 PM] 241.167.2.72:5
'+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Public Class Formatted_DDoS_SampleFlows
Private _open_bracket_delimeter As String
Public Property Open_Bracket_Delimeter() As String
Get
Return _open_bracket_delimeter
End Get
Set(value As String)
_open_bracket_delimeter = value
End Set
End Property
Private _time_received As Date
Public Property Time_Received() As Date
Get
Return _time_received
End Get
Set(value As Date)
_time_received = value
End Set
End Property
Private _close_backet_and_space_delimeter As String
Public Property Close_Bracket_And_Space_Delimeter() As String
Get
Return _close_backet_and_space_delimeter
End Get
Set(value As String)
_close_backet_and_space_delimeter = value
End Set
End Property
Private _source_ip As String
Public Property Source_IP() As String
Get
Return _source_ip
End Get
Set(value As String)
_source_ip = value
End Set
End Property
Private _colon1_delimeter As String
Public Property Colon1_Delimeter() As String
Get
Return _colon1_delimeter
End Get
Set(value As String)
_colon1_delimeter = value
End Set
End Property
Private _source_port As String
Public Property Source_Port() As String
Get
Return _source_port
End Get
Set(value As String)
_source_port = value
End Set
End Property
End Class
+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
' Holds DDoSDetailsInfoResult.
'+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Public Class DDoSDetailsInfoResult
Private _message As String
Public Property Message() As String
Get
Return _message
End Get
Set(value As String)
_message = value
End Set
End Property
Private _ddos_details As New DDoS_Details
Public Property DDoS_Details() As DDoS_Details
Get
Return _ddos_details
End Get
Set(ByVal value As DDoS_Details)
_ddos_details = value
End Set
End Property
End Class
'+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
' Holds DDoS details.
'+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Public Class DDoS_Details
Private _formatted_ddos_sampleflows_list As New List(Of Formatted_DDoS_SampleFlows)
Public Property Formattted_DDoS_SampleFlows_List() As List(Of Formatted_DDoS_SampleFlows)
Get
Return _formatted_ddos_sampleflows_list
End Get
Set(ByVal value As List(Of Formatted_DDoS_SampleFlows))
_formatted_ddos_sampleflows_list = value
End Set
End Property
End Class
Your Formatted_DDoS_SampleFlows class need to define what ToString does.
Something like:
Class Formatted_DDoS_SampleFlows
Public Overrides ToString() As String
Return _open_bracket_delimeter & _time_received.ToString() & _close_backet_and_space_delimeter & _source_ip
End Sub
End Class
use CDate to convert the original value into a Date. The ToString is being operated on the entire class. Then use String.Format to output the date into the correct format you want. Should look something closer to this:
strSampleFlowLine = String.Format("MM/dd/yyyy", CDate(formattedDDoSSampleFlow.something)) & vbCrLf & vbCrLf

List.Find Method in a VB.NET2

Using VB in .NET2
Public Class GroupSID
Private _groupName As String
Private _sid As String
Public Property GroupName() As String
Get
Return _groupName
End Get
Set(ByVal value As String)
_groupName = value
End Set
End Property
Public Property SID() As String
Get
Return _sid
End Get
Set(ByVal value As String)
_sid = value
End Set
End Property
End Class
After the list is populated I want to find the item with the matching groupName (there will be only 1)
Something like (pseudo VB/C#)
'Dim result As GroupSID = ListOfGroupSID.Find(x => x.GroupName == groupName)
https://msdn.microsoft.com/en-us/library/x0b5b5bc(v=vs.80).aspx?cs-save-lang=1&cs-lang=vb#code-snippet-1
from: http://www.codeproject.com/Articles/388257/Csharp-Tips-Using-delegate-in-List-Find-predicate
' expression expected error on Function(p)
Dim result As GroupSID = ListOfGroupSID.Find(Function(p) p.GroupName = groupName)
Problem is VB8/.NET2 doesn't allow this..
Anonymous function (lambda) aren't available in VB8/.Net2 so you have to define your predicate as a separate method :
Function BelongsToSameGroup(ByVal group As GroupSID) As Boolean
Return group.GroupName = groupName ' need to be accessible
End Function
' usage
Dim result As GroupSID = ListOfGroupSID.Find(AddressOf BelongsToSameGroup)

How to access class properties outside the constructor

I'm trying to retrieve my other football attributes (crossing, dribbling, finishing, ball control) that haven't been requested as arguments in the constructor- reportID, playerID and comments are all that are required.
There are over 20 football attributes, so I've just included the first few for readability.
Report Class:
Public Class Report
Public Sub New(ByVal reportID As Integer, ByVal playerID As Integer, ByVal comments As String)
_ReportID = reportID
_PlayerID = playerID
_Comments = comments
End Sub
Private _ReportID As Integer = 0
Private _PlayerID As Integer = 0
Private _Comments As String = ""
Private _Crossing As Integer = 0
Private _Dribbling As Integer = 0
Private _Finishing As Integer = 0
Private _BallControl As Integer = 0
Public Property ReportID() As Integer
Get
Return _ReportID
End Get
Set(ByVal value As Integer)
_ReportID = value
End Set
End Property
Public Property PlayerID() As Integer
Get
Return _PlayerID
End Get
Set(ByVal value As Integer)
_PlayerID = value
End Set
End Property
Public Property Comments() As String
Get
Return _Comments
End Get
Set(ByVal value As String)
_Comments = value
End Set
End Property
Public Property Crossing() As Integer
Get
Return _Crossing
End Get
Set(ByVal value As Integer)
_Crossing = value
End Set
End Property
Public Property Dribbling() As Integer
Get
Return _Dribbling
End Get
Set(ByVal value As Integer)
_Dribbling = value
End Set
End Property
Public Property Finishing() As Integer
Get
Return _Finishing
End Get
Set(ByVal value As Integer)
_Finishing = value
End Set
End Property
Public Property BallControl() As Integer
Get
Return _BallControl
End Get
Set(ByVal value As Integer)
_BallControl = value
End Set
End Property
End Class
Below I realise I'm only adding reportID, playerID and comments to my typeList, which is why I'm getting all 0's for my other attributes. How do access the attributes as well?
Retrieving the data:
Private Function retrieveReport() As List(Of Report)
Dim typeList As New List(Of Report)
Dim Str As String = "SELECT * FROM Report ORDER BY PlayerID"
Try
Using conn As New SqlClient.SqlConnection(DBConnection)
conn.Open()
Using cmdQuery As New SqlClient.SqlCommand(Str, conn)
Using drResult As SqlClient.SqlDataReader = cmdQuery.ExecuteReader()
While drResult.Read
typeList.Add(New Report(drResult("ReportID"), drResult("PlayerID"), drResult("Comments")))
End While
End Using 'Automatically closes connection
End Using
End Using
Catch ex As Exception
MsgBox("Report Exception: " & ex.Message & vbNewLine & Str)
End Try
Return typeList
End Function
Private Sub setReport()
For Each rpt As Report In retrieveReport()
'*****General Information
UC_Menu_Scout1.txtComments.Text = rpt.Comments
'*****Technical
UC_Menu_Scout1.UcAttributes1.lblXCrossing.Text = rpt.Crossing
UC_Menu_Scout1.UcAttributes1.lblXDribbling.Text = rpt.Dribbling
UC_Menu_Scout1.UcAttributes1.lblXFinishing.Text = rpt.Finishing
UC_Menu_Scout1.UcAttributes1.lblXBallControl.Text = rpt.BallControl
UC_Menu_Scout1.UcAttributes1.lblXPassing.Text = rpt.Passing
UC_Menu_Scout1.UcAttributes1.lblXHeadingAccuracy.Text = rpt.HeadingAccuracy
UC_Menu_Scout1.UcAttributes1.lblXMarking.Text = rpt.Marking
UC_Menu_Scout1.UcAttributes1.lblXTackling.Text = rpt.Tackling
'*****Mental
UC_Menu_Scout1.UcAttributes1.lblXAggression.Text = rpt.Aggression
UC_Menu_Scout1.UcAttributes1.lblXPositioning.Text = rpt.Positioning
UC_Menu_Scout1.UcAttributes1.lblXAnticipation.Text = rpt.Anticipation
UC_Menu_Scout1.UcAttributes1.lblXComposure.Text = rpt.Composure
UC_Menu_Scout1.UcAttributes1.lblXVision.Text = rpt.Vision
UC_Menu_Scout1.UcAttributes1.lblXTeamwork.Text = rpt.Teamwork
UC_Menu_Scout1.UcAttributes1.lblXWorkRate.Text = rpt.WorkRate
'*****Physical
UC_Menu_Scout1.UcAttributes1.lblXPace.Text = rpt.Pace
UC_Menu_Scout1.UcAttributes1.lblXBalance.Text = rpt.Balance
UC_Menu_Scout1.UcAttributes1.lblXJumping.Text = rpt.Jumping
UC_Menu_Scout1.UcAttributes1.lblXStrength.Text = rpt.Strength
UC_Menu_Scout1.UcAttributes1.lblXStamina.Text = rpt.Stamina
Next
End Sub
I imagine it's not that hard, so any help would be appreciated please!
To add values to the properties, use With:
typeList.Add(New Report(drResult("ReportID"), drResult("PlayerID"), drResult("Comments")) With {.BallControl = drResult("BallControl"), .Dribbling = drResult("Dribbling")})
You need to assign the property values that you aren't providing to the constructor as arguments, or you can add arguments to the constructor. Try this -- instead of calling the constructor like this:
typeList.Add(New Report(drResult("ReportID"), drResult("PlayerID"), drResult("Comments")))
instead, do this:
dim rep = New Report(drResult("ReportID"), drResult("PlayerID"), drResult("Comments"))
.Crossing = drResult("Crossing")
'additional property assignments
With rep
End With
typeList.Add(rep)

joining 3 table and return

I have 3 table which are Timetable, Schedule and Consultation slot
and i wish to combine them so that all the data are able to retrieve easily
Timetable are having
1. TimetableID
2. Lecture ID
3. ClassVenue
4. ClassStartTime
5. ClassEndTime
Schedule
1. ScheduleID
2. LectureID
3. ScheduleVenue
4. ScheduleStartTime
5. ScheduleEndTime
Consultation Slot
1. ConsultationID
2. LectureID
3. StudentID
4. ScheduleID
5. remark
Here is my code in metadata
Partial Public Class CombinationOfTSC
<Key()> _
Public Property LectureID() As String
Get
Return m_LectureID
End Get
Set(value As String)
m_LectureID = value
End Set
End Property
Private m_LectureID As String
Public Property StudentID() As String
Get
Return m_StudentID
End Get
Set(value As String)
m_StudentID = value
End Set
End Property
Private m_StudentID As String
Public Property ttID() As String
Get
Return m_ttID
End Get
Set(value As String)
m_ttID = value
End Set
End Property
Private m_ttID As String
Public Property ttClassVenue() As String
Get
Return m_ttClassVenue
End Get
Set(value As String)
m_ttClassVenue = value
End Set
End Property
Private m_ttClassVenue As String
Public Property ttClassStartTime() As DateTime
Get
Return m_ttClassStartTime
End Get
Set(value As DateTime)
m_ttClassStartTime = value
End Set
End Property
Private m_ttClassStartTime As DateTime
Public Property ttClassEndTime() As DateTime
Get
Return m_ttClassEndTime
End Get
Set(value As DateTime)
m_ttClassEndTime = value
End Set
End Property
Private m_ttClassEndTime As DateTime
Public Property scID() As String
Get
Return m_scID
End Get
Set(value As String)
m_scID = value
End Set
End Property
Private m_scID As String
Public Property scVenue() As String
Get
Return m_scVenue
End Get
Set(value As String)
m_scVenue = value
End Set
End Property
Private m_scVenue As String
Public Property scStartTime() As DateTime
Get
Return m_scStartTime
End Get
Set(value As DateTime)
m_scStartTime = value
End Set
End Property
Private m_scStartTime As DateTime
Public Property scEndTime() As DateTime
Get
Return m_scEndTime
End Get
Set(value As DateTime)
m_scEndTime = value
End Set
End Property
Private m_scEndTime As DateTime
Public Property cID() As String
Get
Return m_cID
End Get
Set(value As String)
m_cID = value
End Set
End Property
Private m_cID As String
Public Property cRemark() As String
Get
Return m_cRemark
End Get
Set(value As String)
m_cRemark = value
End Set
End Property
Private m_cRemark As String
End Class
In my domain class the code will be
Public Function GetCoTSC(lectureID As String) As IQueryable(Of CombinationOfTSC)
Dim CSC As IQueryable(Of CombinationOfTSC) = From c In ObjectContext.ConsultationSlots Join s In ObjectContext.Schedules On c.ScheduleID Equals s.ScheduleID Join t In ObjectContext.TimeTables On t.LectureID Equals s.LectureID Where c.LectureID = s.LectureID = t.LectureID Select New CombinationOfTSC() With { _
.cID = c.ConsultationID, _
.cRemark = c.Remark, _
.StudentID = c.StudentID, _
.LectureID = s.LectureID, _
.scStartTime = s.ScheduleStartTime, _
.scEndTime = s.ScheduleEndTime, _
.scID = s.ScheduleID, _
.scVenue = s.ScheduleVenue, _
.ttID = t.TimeTableID, _
.ttClassVenue = t.ClassVenue, _
.ttClassStartTime = t.ClassStartTime, _
.ttClassEndTime = t.ClassEndTime}
Return CSC
End Function
I'm having error at c.LectureID = s.LectureID = t.LectureID
I wish to get the combination of 3 tables through the lectureID since there are lecture ID on 3 tables.
Anyone helps pls.
I don't believe you can have x=y=z. Have you tried seperating these out into pairs?
try Where c.LectureID = s.LectureID and s.LectureID = t.LectureID in stead of Where c.LectureID = s.LectureID = t.LectureID

confusion over datagrid erasing entries and general datagrid access

I have a datagrid which I am using LINQ to fill, I then add some custom columns and fill them in programmatically - if the users clicks on the column header to re-sort, all the data in the added columns disappears. I am obviously missing something very basic here but can't seem to see the forest for the trees.
I also have a couple of other questions about how I am doing things:
in my code I am accessing the datagrid custom cells by name, but the cells from the LINQ I have to use a cell reference number (i.e.: (1,2) instead of (total,2) (I realize that the name is replaced by a int) - can I name the columns? How about if the end user re-orders them?
This is one of the first times I have used a datagrid like this so any pointers would be nice.
LINQ code to pull data
Dim query = From m In db.details _
Where m.InboundDate >= CType(MonthCalendar1.SelectionStart, DateTime) _
And m.InboundDate <= CType(MonthCalendar1.SelectionEnd, DateTime).AddHours(23).AddMinutes(59) _
And m.ClientNo = 1 _
Join md In db.Manifests On md.ManifestID Equals m.MainID _
Select m.Zone, m.MainID, m.InboundDate, m.Zip, md.LadingPkgQty, m.Weight
code to fill with data and add columns
billingDatagrid.DataSource = query
billingDatagrid.Columns.Add("Package Rate", "Package Rate")
billingDatagrid.Columns.Add("LTL", "LTL Rate")
billingDatagrid.Columns.Add("Freight", "Freight")
billingDatagrid.Columns.Add("Fuel Surcharge", "Fuel Surcharge")
billingDatagrid.Columns.Add("Linehaul", "Linehaul")
billingDatagrid.Columns.Add("Billed Amount", "Billed")
Code example of how I am accessing the datagrid columns:
Select Case currentZone
Case 1
packageRate = Val(billingDatagrid(4, currentrow).Value) * zone1PkgRate
billingDatagrid("Package Rate", currentrow).Value = packageRate
If Val(billingDatagrid(5, currentrow).Value) > 500 Then
LTLCharge = zone1_ltlBase + (Val(billingDatagrid(5, currentrow).Value) - 500) * zone1_ltlOver
Else
LTLCharge = zone1_ltlBase
End If
billingDatagrid("LTL", currentrow).Value = LTLCharge
At the end of all this I am going to have to create a .csv file for export - it is obviously important that the correst data stay with each row!
Thanks in advance for advice.
You could create a class that has all the columns that you want in the grid and in the linq query select statement create a new instance of the class for each row.
Example:
Public Class GridData
Public Zone as (type here)
...all your other columns from the query
Public PackageRate as (type here)
...all your other columns you add programatically
End Class
Then in the query you can do:
Select New GridData with {.Zone=m.Zone, .MainID=m.MainID, .InboundDate=m.InboundDate, .Zip=m.Zip, .LadingPkgQty=md.LadingPkgQty, .Weight=m.Weight, .PackageRate=Nothing, etc }
With that you just assign the query to the datasource like you are doing and all columns should show up and still be there upon resort. Hope it helps. I think that could solve both your problems since the column names should also be all set, but i didn't test that part.
Edit:
You can assign the value for PackageRate in a loop even before you assign it to the grid datasource.
For each row in query
'you can read and write any of the properties of the GridData Class as row.Client, etc here
Next
Then assign it to the datagrid
OK - This is the final answer - the code work and the data stays where it should --
Thanks for the help!
My Class:
Public Class GridData
Private _clientno
Private _manifest
Private _packagerate
Public Property PackageRate() As Double
Get
Return _packagerate
End Get
Set(ByVal value As Double)
_packagerate = value
End Set
End Property
Public Property manifest() As String
Get
Return _manifest
End Get
Set(ByVal value As String)
_manifest = value
End Set
End Property
Public Property client() As Int16
Get
Return _clientno
End Get
Set(ByVal value As Int16)
_clientno = value
End Set
End Property
End Class
The linq:
Dim query = From m In db.details _
Where m.InboundDate >= CType(MonthCalendar1.SelectionStart, DateTime) _
And m.InboundDate <= CType(MonthCalendar1.SelectionEnd, DateTime).AddHours(23).AddMinutes(59) _
And m.ClientNo = 1 _
Join md In db.Manifests On md.ManifestID Equals m.MainID _
Select New GridData With {.PackageRate = Nothing, .manifest = m.MainID, .client = m.ClientNo}
'No No -- billingDatagrid.Columns.Add("PackageRate", "PackageRate")
and a little code to fill in the packagerate with the value from the client number:
billingDatagrid.DataSource = query
Dim currentrow As Int16 = 0
For Each r In billingDatagrid.Rows
billingDatagrid("PackageRate", currentrow).Value = billingDatagrid("client", currentrow).Value
currentrow += 1
Next
The above code now works...
Thanks.