score:0
you can't return ienumerable<string,string>
. but you can return ienumerable<anonymous tyep>
.
for example :
var currencytables = cultureinfo.getcultures(culturetypes.specificcultures)
.select(s => new regioninfo(s.lcid))
.select(r => new
{
iso = r.isocurrencysymbol,
name = r.currencyenglishname
}).groupby(s => s.iso)
.orderby(r =>r.key)
.select(a => new { iso = a.key, name = a.first().name });
and you can return ienumerable<currencytable>
.
for example:
var currencytables = cultureinfo.getcultures(culturetypes.specificcultures)
.select(s => new regioninfo(s.lcid))
.select(r => new
{
iso = r.isocurrencysymbol,
name = r.currencyenglishname
}).groupby(s => s.iso)
.orderby(r =>r.key)
.select(a => new currencytable{ iso = a.key, name = a.firstordefault().name });
score:3
this one returns all currencysymbols with its first distinct english currency name
var currencysymbols =
cultureinfo.getcultures(culturetypes.specificcultures) //only specific cultures contain region information
.select(x => new regioninfo(x.lcid))
.groupby(x => x.isocurrencysymbol)
.select(x => new currencytable() {
iso = x.key,
name = x.select(y => y.currencyenglishname).distinct().firstordefault()
});
and here goes the linq-version:
var symbols = from x in cultureinfo.getcultures(culturetypes.specificcultures)
let region = new regioninfo(x.lcid)
group region by region.isocurrencysymbol into g
let names = from r in g select r.currencyenglishname
select new currencytable() {
iso = g.key,
name = names.firstordefault()
};
Source: stackoverflow.com
Related Query
- How to get pair value from CultureTypes object in C#?
- How to get bool value as returned object from the generics
- How to get value from Dictionary to new Object in LINQ query
- How to get value from matching key from keyvalue pair list in vb.net using linq?
- How to get the property from a list of object that is a string with the lowest numeric value
- How to get property value from .net dynamic array object
- How to get value from IGrouping where key and value in object match
- How to get nested key value pair from dictionary with linq
- How to get key value pair from appSettings into a collection of SelectListItem?
- How can I get a column value from selected database object in ListBox?
- How can I get LINQ to return the object which has the max value for a given property?
- How to get first object out from List<Object> using Linq
- How to get MAX value from Dictionary?
- How to get value of child node from XDocument
- Using LINQ, how do I find an object with a given property value from a List?
- How to get item from dictionary by value of property
- How to get an object from a list based upon IEqualityComparer<T>
- How do I get the value from a specific node in an XML file?
- How can I get LINQ to return the index of the object which has the max value in a collection?
- How to Deal With Dapper return Key Value pair with Dynamic from LINQ
- How to get the last value from a model list without looping it in MVC?
- how to get value from xml by Linq
- How to get Count of value of nested object by linq
- LinqExpression: How do I get the value from comparison evaluation
- How to abstract a value from an object within an object?
- Get minimum and maximum time value from list of object property using Linq
- C# LINQ How to get a data source from a db?
- How do I get the first value from this collection using Linq to Entities?
- How to get the highest value from a datatable?
- how to read value from a session object
More Query from same tag
- Get Count and Distinct items with LINQ query?
- Is Linq to SQL faster than Linq to Entities?
- Will LINQ use specialized/optimized versions of functions based on the type of the input?
- comparing two folders for non identical files?
- List of XPaths on XElement
- Linq query where in list, performance what is the best?
- Change order of XML using XDocument
- SQL query with JOIN to LINQ
- Making a custom class availabe to LINQ queries
- How read list items in list using linq in C#?
- Convert where clause containing select to Linq
- Linq orderby several words
- Like statement for datetime in SQL ASP.NET MVC
- Overriding generic IEnumerable interface in child class
- Linq group by groups
- Filter data from 2 lists with diferent models C#
- LINQ to identify a row that is the first in consecutive occurrences that meet criteria
- Exclude multiple items from SelectList in mvc
- How to change the data layout of a data table with LINQ
- Resultant LinQ Query to a new DataTable
- Return multiple attributes of an element to a list. LINQ to XML
- Order one list with a parameter from another list, with a joinable parameter
- How to find like integers in multiple list
- How to fill sublist which has another join
- Project attribute values
- Filter a list of string with wildcard
- Find the sum of all count properties in child nodes
- Converting SQL code with Row_Number() into LINQ C# code
- Conditional generic Where equals clause in Entity Framework
- Linq deferred execution in asp.net