Load values via junctions table

空扰寡人 提交于 2019-12-12 02:46:05

问题


I need to load all the rows from the ItemToGroup table into one field separated with a comma, I can't use String.Join since I'm using server mode from DevExpress, it loads the data dynamically from the database on demand. And String.Join only works on generic lists.

I tried this LINQ Statement:

e.QueryableSource = From c In sqlData.ItemStores
Select c.Price, c.Status,
ItemGroupNames = c.ItemToGroups.Select(Function(g) g.ItemGroup.ItemGroupName)

Problem is that in the grid column it shows:

System.Collections.Generic.List`[system.string]


回答1:


If you just want to show your field values in UI then you can use ColumnView.CustomColumnDisplayText event and in this event you can use String.Join.
Here is example:

Private Sub gridView1_CustomColumnDisplayText(sender As Object, e As CustomColumnDisplayTextEventArgs) Handles gridView1.CustomColumnDisplayText

    Dim list = TryCast(e.Value, List(Of String))

    If Not list Is Nothing Then
        e.DisplayText = String.Join(", ", list)
    End If

End Sub


来源:https://stackoverflow.com/questions/32213326/load-values-via-junctions-table

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!