Reputation: 33744
<@[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...
I understand that my explanation could be some messy , so ask if you can't get it. I want to know is there any way to use Count(Name) where Name = OneOfNames inside closure or linq2sql ?
Upvotes: 0
Views: 248
Reputation: 62975
I can't compile to verify that this works at the moment, but try the following:
<@ linq.TrueIncidents
|> Seq.groupBy (fun i -> i.Name)
|> Seq.map (fun (name, is') -> name, Seq.length is') @>
|> query
|> Map.ofSeq
This should give you a Map<string, int>
of each name and its respective number of occurrences.
Upvotes: 2