Join Olivia Chiu Stone for an in-depth discussion in this video Use the let keyword, part of LINQ with C# Essential Training.
- Basic queries only need one range variable.…In this more complex query,…using the into keyword requires the creation…of a new temporary sequence…to store the range variable.…If multiple range variables were needed,…a better way to write the same query…would be to use the let keyword instead.…The let keyword introduces a new range…or local variable that can be used…within a query using comprehension syntax.…Before I begin modifying this code,…I'll run it once to see the expected results.…
My customers shown are those…that have spent more than 500 euros…and are in order of their last name.…Now I can modify the query…to use the let keyword instead of into.…I remove the select and into clauses…and use let to define a variable called euro,…which is equal to the price property…from the customer element…multiplied by 0.89.…Now, I'll update the where clause…to use the local variable euro for the criteria.…
Finally, the orderby and select clause…can reference the original range variable c,…since it is still in scope for me to use.…
AuthorOlivia Chiu Stone
In LINQ with C# Essential Training, engineer Olivia Chiu introduces techniques for querying, updating, and transforming data with LINQ. She covers standard queries—such as finding overlaps in two datasets and creating hierarchies—as well as complex chained queries. She also shows how to group and join LINQ queries with lambda expressions, and use LINQ to query SQL databases and XML documents. Last but not least, Olivia provides tips for optimizing the performance of your queries.
- Creating and executing a LINQ query
- Returning results
- Changing the data source type
- Performing standard queries
- Working with lambda expressions
- Chaining and complex queries
- Querying SQL and XML
- Performing tree queries
- Using sequences, elements, and scalars
- Allocating memory
Skill Level Intermediate
1. Introduction to LINQ
Common use cases1m 45s
2. Basic LINQ Queries
3. Data Transformation
Return results as a new type1m 39s
4. Type Relationships
5. Standard Queries
6. Lambda Expressions
7. Complex Queries
8. LINQ to SQL
9. LINQ to XML
10. Other Operators
- Mark as unwatched
- Mark all as unwatched
Are you sure you want to mark all the videos in this course as unwatched?
This will not affect your course history, your reports, or your certificates of completion for this course.Cancel
Take notes with your new membership!
Type in the entry box, then click Enter to save your note.
1:30Press on any video thumbnail to jump immediately to the timecode shown.
Notes are saved with you account but can also be exported as plain text, MS Word, PDF, Google Doc, or Evernote.