How to combine MS Access columns with Dapper using VB.NET?
Please guide.
Private iService As New Itemservice2()
Private Sub Form2_Load(sender As Object, e As EventArgs) Handles MyBase.Load
DataGridView1.DataSource = iService.Getitem()
End Sub
Public Function Getitem() As IEnumerable(Of Stocks)
Dim sql = "SELECT * FROM Stocks"
Using _conn = New OleDbConnection(DbContext.GetOledbConnectionString())
Return _conn.Query(Of Stocks)(sql).ToList()
End Using
End Function
Public Class Stocks
Public Property Id() As Integer
Public Property CodeProduct() As String
Public Property Colorcode() As String
Public Property Size() As String
Public Property Qty() As Integer
End Class
Result from function Getitem
in datagridview:
Id | CodeProduct | Colorcode | Size | Qty |
---|---|---|---|---|
1 | KBT 1809 | S | 10 | |
2 | KBE 0927 | BHTF07KP | M | 30 |
Desired result from function Getitem
in datagridview:
Id | Combine | Qty |
---|---|---|
1 | KBT 1809 S | 10 |
2 | KBE 0927 BHTF07KP M | 30 |
My VB is rusty to say the least, but you should be able to declare a readonly property like this:
Public Class Stocks
Public Property Id() As Integer
Public Property CodeProduct() As String
Public Property Colorcode() As String
Public Property Size() As String
Public Property Qty() As Integer
Public ReadOnly Property Combine() As String
Get
Return String.Concat(CodeProduct, " ", Colorcode, "", Size).Trim()
End Get
End Property
End Class
Then you need to hide the superfluous columns in the grid view.