0
<@[for i in linq.TrueIncidents -> i.RecTime, i.Name ] @> |> query |> Array.ofSeq

How can I get counts of different names ?

just count(Name) where Name = somename...

I think first I must select form here all Names with |> Seq.distinctBy(fun x -> x.Name) and then make Seq.Count() different selects where Name will be one of names and then union all the selects ... really wierd way.

Or I can use it as object later with closure with int ref counters for each distincted Name...

私の説明がややこしいかもしれないことは理解していますので、理解できない場合は質問してください。Count(Name) where Name = OneOfNames をクロージャーまたは linq2sql 内で使用する方法はありますか?

4

1 に答える 1

2

現時点ではこれが機能することを確認するためにコンパイルすることはできませんが、次のことを試してください。

<@ linq.TrueIncidents
   |> Seq.groupBy (fun i -> i.Name)
   |> Seq.map (fun (name, is') -> name, Seq.length is') @>
|> query
|> Map.ofSeq

これMap<string, int>により、各名前とそれぞれの出現回数が得られます。

于 2011-04-06T09:25:11.977 に答える