score:3
Accepted answer
You can use the let
clause to declare intermediate variables:
XDocument reportDoc = XDocument.Load(@"Report.xml");
var query = from item in reportDoc.Element("Root").Descendants()
let x = Convert.ToInt32(ticket.Element("X").Value)
let y = Convert.ToInt32(ticket.Element("Y").Value)
select new Item()
{
X = x,
Y = y
Z = x * y
};
Source: stackoverflow.com
Related Query
- How to set a DTO's property value directly in LINQ select statement
- How to use LINQ to select object with minimum or maximum property value
- How to dynamically get a property value in which is in another property with Linq where statement
- How to set value in nested LINQ select to parent select result?
- How to select new object set property = other property value
- How to set a property value to null when select items in a list
- How to set property value using Expressions?
- How to use Lambda in LINQ select statement
- How set value a property selector Expression<Func<T,TResult>>
- LINQ How to select more than 1 property in a lambda expression?
- C# LINQ Select objects with the same value of one property join values of other
- In LINQ to objects, how to set an object property to null if it equals "folder"?
- How to Except Property instead of Select in Lambda LINQ
- How can I make my Linq select return values if the value selected is null?
- How to use If statement during select from Linq to Datasets
- how to deal with exception in LINQ Select statement
- LINQ - How can I give a child object in a select statement a reference to its parent?
- C# Linq - how to select top 5 rows from a List<string> splitting on the first value
- How to select objects with highest value of Property A, grouped by Property B?
- LINQ Query How to select Max value between start and end index and the index of the max value
- How to treat null value in Linq Select
- How to make select statement Dynamic ? Linq
- How to select by child collection value in LINQ
- How do i use an Expression<Func<T>> in a linq statement if my navigation property is a single item?
- LINQ Query How to select Max value between start and end index
- linq to xml: how to select the value from elements
- How to select all objects that have a property value in list of values?
- LINQ - How to change value in select or foreach loop?
- How to get 0 out of a null linq query value when a condition isn't met and then set it to a ViewBag
- How to select two set from collection in linq
More Query from same tag
- LINQ Modelling Column Name Same As Table Name
- Use Regex in this Linq query?
- Select from list linq
- Not able to Update the LINQ list
- Select the first rows from a datatable by LINQ
- How to return unique column with the max version of another column in Linq to SQL?
- Linq Group get percentage of overall
- How can I join a many to many relationship with linq
- How can I store Linq to Sql objects in session using Windows Azure Cache Service (Preview)
- I want to fetch the data of child node from XML using C# Linq
- how to bind data to dropdown (data comes from a linq query) using jquery?
- Converting SQL to LINQ: Rolling Average
- Data table diff based on multiple columns
- How do I .OrderBy() and .Take(x) this LINQ query?
- How do I get the SQL command text when I insert a new record with Linq?
- Filtering Linq Query with Virtual Icollection Property
- Dynamic Lambda Expression call
- ObservableCollection from Linq
- c# how to check if query result is empty as opposed to null
- What datatype does linq return?
- How to update two columns with same name from two tables in a join query
- Populating textboxes using LINQ2SQL
- Linq statement fails with dynamic where clause
- How do I get this result using LINQ?
- c# linq with selectMany to sql statement
- A Problem in Linq expression
- Take a sequence of elements from an array from i to j using C# and extension method
- Traversing through Linq Result gives Object Reference Not Set to Instance
- Outer Joining two Data Tables on multiple criteria
- get data from database that falls in between 2 dates