One, in the actual demand we will exist to select a set, and then we need to use some of the collection of fields to calculate the repetition, and statistical repetition of the number, then we can be used to filter and repeat LINQ.
Two, the following code:
usingSystem;usingSystem.Collections.Generic;usingSystem.Linq;usingSystem.Text;usingSystem.Threading.Tasks;namespacebao{classProgram {Static voidMain (string[] args) {List<Demo> result =NewList<demo>(); Result. ADD (NewDemo () {Name="1", Pro="1", Code="1" }); Result. ADD (NewDemo () {Name="1", Pro="1", Code="1" }); Result. ADD (NewDemo () {Name="2", Pro="2", Code="3" }); Result. ADD (NewDemo () {Name="3", Pro="3", Code="3" }); Result. ADD (NewDemo () {Name="4", Pro="4", Code="4" }); varTest = fromAinchresultSelect New{schoolname=A.name, Province=A.pro, Schoolcode=A.code, Counts= ( fromTinchresultwhereT.name = = A.name && T.pro = = A.pro && T.code = =A.code Group T byNew{Name = t.name, Pro = T.pro, Code =T.code} into GSelect New{counts =G.count ()}). FirstOrDefault (). counts}; varTTT =test. ToList (); varAAA =TTT. Distinct (). ToList (); } } Public classDemo { Public stringCode {Get;Set; } Public stringName {Get;Set; } Public stringPro {Get;Set; } Public intCounts {Get;Set; } }}
C#linq calculate the total number of bars and repeat the notation