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

Scott Klein

"Professional LINQ"

Employee")]
public class Employee
{
[Column(DBType = "int", IsPrimaryKey = true, IsDBGenerated = true,
CanBeNull = false)]
public int EmployeeID;
[Column(DBType = "int", CanBeNull = false)]
public int ContactID;
[Column(DBType = "nvarchar(256) not null")]
public string LoginID;
[Column(DBType = "nvarchar(15) not null")]
public string NationalIDNUmber;
[Column(DBType = "int")]
public int ManagerID;
private EntityRef _Contact;
[Association(Storage = "_Contact", ThisKey = "ContactID")]
public Contact Contact
{
get { return this._Contact.Entity;}
set { this._Contact.Entity = value;}
}
}
249
Part III: LINQ to SQL
This example illustrates the relationship between a contact and employee. The EntityRef type is used to
define the relationship from Employee back to Contact.
With the classes and relationship defined, you can now write a query that utilizes the relationship, like
this:
IQueryable empQuery =
from emp in db.Employee
where emp.Contact.FirstName.StartsWith("Scott")
select emp;
You can see that EntitySet and EntityRef are complementary and quite easy to use, and are powerful
for defining relationships.


Pages:
377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401
hotel jelenia góra Russian bride Free English grammar and study guid powiekszenia wielkoformatowe counter strike 1.6