score:1
Accepted answer
var output = (from r in trades
join p in refdata on r.payindex equals p.indexlabel
into g1
from s in g1.defaultifempty()
join t in refdata on r.recindex equals t.indexlabel into g2
from a in g2.defaultifempty()
select trade { id=r.id,payindex=r.payindex,recindex=r.recindex, reccurrency = a != null ? a.symbol : "", paycurrency = s != null ? s.symbol : ""}).tolist();
score:0
var output = (from r in trades
join p in refdata on r.payindex equals p.indexlabel
into g1
from s in g1.defaultifempty()
join t in refdata on r.recindex equals t.indexlabel into g2
from a in g2.defaultifempty()
select new { r, recsymbol = a?.symbol, paysymbol = s?.symbol }).tolist();
output.foreach(o =>
{
o.r.paycurrency = o.paysymbol;
o.r.reccurrency = o.recsymbol;
});
Source: stackoverflow.com
Related Query
- Updating Collection from other collection for matching items
- Linq intersect or join to return items from one collection that have matching properties to another?
- Linq Find all items in collection from an other collection
- Best way to remove multiple items matching a predicate from a .NET Dictionary?
- linq select items from child collection
- Entity Framework recursively include collection for each entity from included collection
- Find And Remove Items From Collection
- Linq: How to query items from a collection until the sum reaches a certain value
- C# find all matching Items from a List<Item>
- Return Type for Collection from LINQ Query
- linq how to select the parent from a collection where the parent contains child items in another collection
- Most efficient collection for storing data from LINQ to Entities?
- C#: How to remove items from the collection of a IDictionary<E, ICollection<T>> with LINQ?
- How to get list for a property of a class from its collection
- Fastest way to get matching items from two list c#
- Filtering a collection of items from contents of another collection
- Linq way of checking that no items in a collection match any other item
- Optimized way to select items from a Collection excluding a list of certain member using Linq
- Update one observableCollection from other collection
- LINQ for removing elements that are started with other element from list
- Is there a Linq operation to determine whether there are items in a collection who have the same values for a pair of properties?
- Get Min and Max for items from database using Linq
- Get list of all items of a generic type from list which could contain other types
- Most efficient way to remove items from a list without running into a collection modified exception?
- Can we use Linq for geting value from collection object in java?
- Remove items from collection using linq
- Iterating through collection items and checking each property for a valid value
- Linq to objects - Search collection with value from other collection
- Remove Items from sub list matching another sub list with Linq
- What is the fastest non-LINQ algorithm to 'pair up' matching items from multiple separate lists?
More Query from same tag
- Linq list of string match any inside string
- Nested 3 Tier LINQ Query
- How do I simplify a LINQ query with multiple .Select() in order to return an IQueryable(int)
- Left Join in Linq and using the variable for other joins
- Sort List of parent class by property of subclass using LINQ
- Iterating through IQueryable with foreach results in an out of memory exception
- How to get mismatch position using Linq or lambda operation on two string array
- convert sql query to LINQ statement
- Unexpected results in Linq query
- How to apply Where, Select, OrderBy and so on to the result of a stored procedure in LinqPad?
- C# Linq where list in list
- Add elements to XDocument after LINQ Query
- Linq query using only year part of datetime
- How to build a dynamic FROM clause for a LINQ query?
- How to remove common objects from two lists with linq
- SUM and DISTINCT of two different columns
- The cast to value type 'Decimal' failed because the materialized value is null
- C# List to Dictionary without Foreach [ERROR]
- Create my own LINQ collection
- linq expression in vb.net
- How to execute a LINQ query while constructing an XDocument?
- Removing duplicates without Linq for IList of IList
- query base object based on a non related entity list using entity framework
- c# Loop List<T> row and trim column values
- LINQ to Entities does not recognise custom method
- LINQ, GroupBy inner value of field which has type of object
- How do I join a list of dates with database table in entity?
- Equation - Math.Round and double
- Using Variables to call a table and columns in Linq to Sql
- Filter a query using value of XElement within XML using LINQ C#