LINQ的函數集合我已經在C#3.0的介紹LINQ專題中提過了,這裡我們將仔細講解每一個函數的用法。基於VS2005 Beta1版本,也許在將來微軟會改變名字,大家自己注意。
今天先準備一下以後要用到的類:
class Person
...{
int _id;
int _idRole;
string _lastName;
string _firstName;
public int ID
...{
get ...{ return _id; }
set ...{ _id = value; }
}
public int IDRole
...{
get ...{ return _idRole; }
set ...{ _idRole = value; }
}
public string LastName
...{
get ...{ return _lastName; }
set ...{ _lastName = value; }
}
public string FirstName
...{
get ...{ return _firstName; }
set ...{ _firstName = value; }
}
}
class Role
...{
int _id;
string _roleDescription;
public int ID
...{
get ...{ return _id; }
set ...{ _id = value; }
}
public string RoleDescription
...{
get ...{ return _roleDescription; }
set ...{ _roleDescription = value; }
}
}
class Salary
...{
int _idPerson;
int _year;
double _salary;
public int IDPerson
...{
get ...{ return _idPerson; }
set ...{ _idPerson = value; }
}
public int Year
...{
get ...{ return _year; }
set ...{ _year = value; }
}
public double SalaryYear
...{
get ...{ return _salary; }
set ...{ _salary = value; }
}
}
以上是三個以後常用的類,分別為Person,Role和Salary類。他們之間的關係應該一看就能看出來。我就不在說了。沒什麼複雜的。