score:26
Accepted answer
linq is designed for querying. if you're trying to set things, you should definitely use a loop (probably foreach
). that doesn't mean you won't be able to use linq as part of that loop, but you shouldn't be trying to apply a side-effect within linq itself.
score:0
query the otheritems first. do a todictionary() on the result. then, when querying the database, do this:
var items = from i in context
select new myclass
{ a = i.a,
b = otheritems[i.a],
c = i.c
}
Source: stackoverflow.com
Related Query
- How can I set properties on all items from a linq query with values from another object that is also pulled from a query?
- How to filter linq query based on all of the values of one property from another list
- How to use LINQ to find all combinations of n items from a set of numbers?
- linq - how do you do a query for items in one query source that are not in another one?
- How can i select all values from a nested dictionary with linq?
- How to sort linq with fixed values and show all the rest with another sorting
- How can I make a LINQ query with subqueries in the from statement?
- How to generate a LINQ query that queries all non-null properties from a search page model
- How can I use Linq with JSON to get all the Ids from this odd JSON?
- How to write a LINQ query to select from a collection with given set of matching IDs
- How can can i read values from linq query in AspNetCore?
- How to use LINQ to retrieve a list from another entity with a specific number of items
- Select all fields from collection with related items in another collection using LINQ
- How can I insert all rows from one table into another table with Linq-to-SQL?
- How to set Filter Values in LinQ with SQL Query Text?
- How to change values of few properties from one list to another using LINQ C#:
- Linq query to get count with multiple column values coming from condition on another column
- How can I use Linq to find items with matching words from a comma separated string?
- How to match value from textbox to dictionary and display it in another textbox on button click with linq query in C#
- How can I access all values from a specific column in tables using linq and Entity Framework?
- How can i get all subnode values separately from XML Response using LINQ to XML?
- Using LINQ and Entity Framework, how can I just populate some properties of a Dbo with data from the DB?
- How can I use a LINQ statement to filter out items that matches one of the words from another List?
- How to construct a LINQ Query to test a list against another list where elements start with the elements from the other
- How can I use my class properties in my Linq query with group by statement?
- Linq to update a collection with values from another collection?
- Linq - How to select items from a list that contains only items of another list?
- How can I iterate over a collection and change values with LINQ extension methods?
- How can I build Linq query with dynamic OR statements?
- How to understand the following C# linq code of implementing the algorithm to return all combinations of k elements from n
More Query from same tag
- Unexpected behavior in entity framework
- Is there an IEnumerable implementation that only iterates over it's source (e.g. LINQ) once?
- Linq to Entities Querying for Nullable data types
- Sending data with viewbag
- Joins with more than 2 or 3 tables, with Where clause using Lambda Expressions. Then sending the object to the View
- how to return back list of data from controller to knockout function to view page
- What is the most elegant way to create a list of boolean of 100 elements initialized at false
- Difference between the returned values of two selector functions in this code
- change repeated fields
- Checklist Box Selected Items from LinQ
- Linq Where Clause 'AND' 'OR'
- Skip and Take is generating exception in Entity Framework
- What is the equivalent argument matcher for a parameter like this - "Expression<Func<TEntity, bool>> predicate)" in NSubsitute?
- Get how many times an array appears in a List<>
- select object which has same one property and different another
- How to return rows with max value one column grouped by another column?
- Use Html.DisplayNameFor with IEnumerable<IGrouping>
- Linq, how can I do flexible sorting?
- Group by an array inside an array using Linq
- Linq-to-Sql: recursively get children
- C# Linq List Contains Similar Elements
- Combining data in two ILists containing missing values and duplicates
- Accessing Linq data in telerik grid ItemCreated method
- CompareTo operator in breeze
- LINQ to Entities does not recognize the method [Type] GetValue[Type]
- Get column name by value of field in datarow
- Argument Exception in Dictionary Getter
- substring in conjunctions with datatable query
- How to extract items at specified locations from list of comma separated strings using LINQ
- How can I produce a join on a substring and an integer in Entity Framework?