O'Reilly logo

Pro LINQ: Language Integrated Query in C# 2008 by Joseph C. Rattz Jr.

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

Database Views

When I generate the entity classes for the Northwind database in Chapter 12, I specify the /views option to have entity class mappings for database views created, but I have yet to mention views and how to query them. The entity class generation tools, SQLMetal and the Object Relational Designer, declare a Table<T> property in the [Your]DataContext class for each database view and create a corresponding entity class T. You query them just like tables. In general, they behave just like tables except for the fact that they are read-only.

Because the entity classes generated for views do not contain entity class properties that are mapped as primary keys, they are read-only. If you consider that without primary keys, the DataContext ...

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