操作 DataTable
操作 DataTable
let table = new System.Data.DataTable()
table.Columns.Add("Id", System.Int16().GetType())
//table.Columns.Add("Id", System.Type.GetType("System.String"))
table.Columns.Add("XM", System.Type.GetType("System.String"))
table.Rows.Add(1,"100") www.zzzyk.com
table.Rows.Add(2,"200")
table.Rows.Add(3,300)
table.Rows.Add(5,500)
// 原始的二维序列格式
let q = query { for r in table.Select() do yield r.ItemArray }
// 打印出二维序列
q |> Seq.iter ( fun i -> printfn "%A" i )
q |> Seq.iter(fun n ->
n |> Seq.iter(fun i -> printf "%A," i); printfn ""
)
// 输出成普通的二维文本格式
let q2 = query {
for r in table.Select() do
let t =
r.ItemArray |> Seq.map ( fun i -> i.ToString() )
|> Seq.reduce ( fun a b -> a + "," + b )
yield t
}
|> String.concat ("\r\n")
操作 DataTable
let table = new System.Data.DataTable()
table.Columns.Add("Id", System.Int16().GetType())
//table.Columns.Add("Id", System.Type.GetType("System.String"))
table.Columns.Add("XM", System.Type.GetType("System.String"))
table.Rows.Add(1,"100")
table.Rows.Add(2,"200")
table.Rows.Add(3,300)
table.Rows.Add(5,500)
// 原始的二维序列格式
let q = query { for r in table.Select() do yield r.ItemArray }
// 打印出二维序列
q |> Seq.iter ( fun i -> printfn "%A" i )
q |> Seq.iter(fun n ->
n |> Seq.iter(fun i -> printf "%A," i); printfn ""
)
// 输出成普通的二维文本格式
let q2 = query {
for r in table.Select() do
let t =
r.ItemArray |> Seq.map ( fun i -> i.ToString() )
|> Seq.reduce ( fun a b -> a + "," + b )
yield t
}
|> String.concat ("\r\n")
//这一句也可以写成
//|> Seq.reduce ( fun a b -> a + "\r\n" + b )
// 打印出文本
printfn "%A" q2
// 打印出文本
printfn "%A" q2
补充:综合编程 , 其他综合 ,