SEARCH
0-9 A B C D E F G H I J K L M N O P Q R S T U V W X Y Z
Prev | Current Page 32 | Next

Scott Klein

"Professional LINQ"


To illustrate this, let??™s modify the directory example from earlier in this chapter. One of the great things
about LINQ is that it enables you easily to ??????map??™??™ object-oriented objects within your .NET programming
language to a database and the objects within a relational database. That means you can access those
relational objects in a strongly typed, object-oriented manner.
8
Chapter 1: Project LINQ
To do this, a mapping to the database needs to be made, and that is accomplished by creating and
declaring two classes. Those classes map the relational objects into the object-oriented world. The first
class maps the actual database:
[Database(Name="AdventureWorks")]
public class AdventureWorks : DataContext
{
public AdventureWorks(string connection) : base(connection) {}
public Table DirectoryInformation;
}
The second class maps the table and columns of the table you want to access:
[Table(Name="DirectoryInformation")]
public class DirectoryInformation
{
[Column(DbType="varchar(50)")]
public string DirectoryName;
[Column(DbType = "varchar(255)")]
public string DirectoryDescription;
}
The class name maps to the table in the database you want to access, and the columns are mapped by
adding metadata to a couple of variables.


Pages:
20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44
hotel jelenia góra Russian bride Free English grammar and study guid powiekszenia wielkoformatowe counter strike 1.6