LINQ (Language Integrated Query) and Fixed Income Applications
19.1 INTRODUCTION AND OBJECTIVES
In this chapter we give an introduction to LINQ (Language Integrated Query) and we give a number of examples and applications to fixed income. What is LINQ? It is a set of language and framework features that allows developers to write structured type-safe queries based on different kinds of data sources, for example:
In all cases we wish to extract data from some local (in-memory) data collection or from remote (on disk) data sources. We retrieve data in some way by querying the data source. A local query uses a local collection as its data source while an interpreted query uses a remote data source. Local queries operate on collections that implement IEnumerable<> and they resolve to query operators in the Enumerable class. Interpreted queries, on the other hand, are descriptive. They operate on sequences that implement IQueryable<> and they resolve to the query operators in the Queryable class that emits expression trees that are interpreted at run-time.
We discuss LINQ queries, LINQ operators and the LINQ binding to a number of data sources. We also give a number of simple examples to show how to familiarise yourself with LINQ as well as ...