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 329 | Next

Scott Klein

"Professional LINQ"


OtherKey Identifies one or more members of
the target entity class as key values
on the other side of the association.
The following example shows how the Association attribute is used to define an association:
[Association(Name = "FK_Employee_Contact_ContactID",
Storage = "_Employee", ThisKey = "ContactID", IsForeignKey = true)]
public Employee Emp
{
get { return this._Employee.Entity; }
set { this._Employee.Entity = value; }
}
The association is applied to a table in which you need to reference the associated table.
In the following example, the Contact class contains an Employee property that??™s tagged with the
Association attribute, providing the Contact class with a relationship to the Employee class:
[Table(Name = "Person.Contact")]
public class Contact
{
[Column(DBType = "nvarchar(8) not null")]
public string Title;
206
Chapter 10: LINQ to SQL Overview
[Column(DBType = "nvarchar(50) not null")]
public string FirstName;
[Column(DBType = "nvarchar(50) not null")]
public string MiddleName;
[Column(DBType = "nvarchar(50) not null")]
public string LastName;
[Column(DBType = "nvarchar(50) not null")]
public string EmailAddress;
[Column(DBType = "int")]
public int EmailPromotion;
private EntityRef _Employee;
[Association(Name = "FK_Employee_Contact_ContactID",
Storage = "_Employee", ThisKey = "ContactID", IsForeignKey = true)]
public Employee Emp
{
get { return this.


Pages:
317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341
hotel jelenia góra Russian bride Free English grammar and study guid powiekszenia wielkoformatowe counter strike 1.6