Programming Microsoft LINQ

The best way to write queries using LINQ to SQL is by having a DataContext-derived class in your code that exposes all the tables, stored procedures, and user-defined functions you need as properyies of a class instance. You also need entity classes that are mapped to the data-base objects. As you have seen in previous chapters, this mapping can be made by using attributes to decorate classes or through an external XML mapping file.