O'Reilly logo

C# for Financial Markets by Andrea Germani, Daniel J. Duffy

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

19

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:

  • Local object collections (any collection that implements the IEnumerable<> interface can be used with LINQ).
  • Databases (for example, LINQ to SQL entity classes).
  • XML data.
  • A number of third-party products such as LINQ to Excel, 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 ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required