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

Scott Klein

"Professional LINQ"


[Table(Name="Person.Contact")]
public class Contact
{
[Column(DBType = "nvarchar(8) not null")]
public string Title;
[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;
}
With the schema defined, a query can be issued.
private void button1_Click(object sender, EventArgs e)
{
DataContext context = new DataContext("Initial Catalog=AdventureWorks;Integrated
Security=sspi");
Table contact = context.GetTable();
var query =
from c in contact
select new { c.FirstName, c.LastName, c.EmailAddress} ;
foreach (var item in query)
listBox1.Items.Add(item.FirstName + " " + item.LastName + " " +
item.EmailAddress);
}
What you want to notice is that although the object (c) contains five fields, the sequence being returned
contains only three fields: FirstName, LastName, and EmailAddress. That is the strength of anonymous
types, in that you can return a portion of the information in the object.


Pages:
48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72
hotel jelenia góra Russian bride Free English grammar and study guid powiekszenia wielkoformatowe counter strike 1.6