F#查询表达式/选择运算符/在结果中更改列标题 [英] F# Query Expression / select operator / changing column headings in result
本文介绍了F#查询表达式/选择运算符/在结果中更改列标题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
在以下代码中:
#r "System.Data.dll"
#r "FSharp.Data.TypeProviders.dll"
#r "System.Data.Linq.dll"
open System
open System.Data
open System.Data.Linq
open Microsoft.FSharp.Data.TypeProviders
open Microsoft.FSharp.Linq
open System.Windows.Forms
type dbSchema = SqlDataConnection<"...">
let grid<'T> (x:seq<'T>) =...
let query1 =
query {
for row in db.Status do
//select row
select (row.StatusID, row.Name)
}
query1 |> Seq.toArray |> grid
将列更改为有意义的标题(例如,数据源中的实际列)而不是仅将其更改为(Item1 Item2 ...)的更好方法是什么.
What are the better ways to change columns to meaningful headings (e.g. actual Column from data source) instead of of just (Item1 Item2...).
注意:有关网格功能,请请参阅 Tomas Petricek的回应.
Note: For grid function, please see Tomas Petricek response.
关于,IP
推荐答案
您可以选择数据作为记录,以允许 DataGridView
推断列的名称
You can select the data as a record to let DataGridView
infer the names of the columns
type Status =
{
StatusID: int
Name: string
}
let query1 =
query {
for row in db.Status do
select { StatusID = row.StatusID; Name = row.Name }
}
这篇关于F#查询表达式/选择运算符/在结果中更改列标题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文