c# - Linq: using StringComparer with GroupBy/Distinct in query syntax -


I have this (XLinq) query and wondered how it can be converted to the Conveyor syntax: < / P>

  var grouped = doc.Descendants () .GroupBy (t = & gt; t.Element (ns + "GroupingAttr"). Value, StringComparer.OrdinalIgnoreCase);  

This string syntax is without the compairer:

  var grouped = doc.Descendants in (t) group t. Element (group selection of NSS Group Group Group)  

My group is a bit more complex, so I prefer to use the group key instead of presenting a new property.

This is what I have tried but does not work because the "key" is not available in the context of selection (I use my more complex key definition to clarify the fact that I do not want to choose To repeat it):

  var grouped = to doc.Descendants () Let's key = ((t.Name! = Ns + "SomeElementName")? T.Element (ns + ElementValueOrDefault ("Empty Group") Group by Key T. Choose ToUpper () in G new {Name = Key, Item = G};  

Related Questions:

I do not seem to Security that you can use within the query syntax Tulnakrta, although you can call ToUpper on its value. This will ignore the case for you. Using Toower is more efficient than using ToLower as a side note, so there will be a way to go toUpper.

The C # team was very rare that they introduced in the query syntax, so for this something like 'Extension methods syntax must be used.


Comments

Popular posts from this blog

c++ - Linux and clipboard -

What is expire header and how to achive them in ASP.NET and PHP? -

sql server - How can I determine which of my SQL 2005 statistics are unused? -