通过连接表加载值 [英] Load values via junctions table
问题描述
我需要将 ItemToGroup
表中的所有行加载到一个用逗号分隔的字段中,我不能使用 String.Join
因为我使用DevExpress的服务器模式,它会根据需要从数据库动态加载数据。而 String.Join
只适用于通用列表。
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.
我尝试过这个LINQ语句:
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]
推荐答案
如果您只想在UI中显示您的字段值,则可以使用 ColumnView.CustomColumnDisplayText
事件a在这种情况下,您可以使用 String.Join
。
这里是示例:
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
这篇关于通过连接表加载值的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!