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

Scott Klein

"Professional LINQ"

It strongly types
the DataContext and includes a reference to a strongly typed table.
The bulk of your form code should now look like this:
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
}
public class AdventureWorks : DataContext
{
public AdventureWorks(string connection) : base(connection) {}
public Table Contact;
}
The strongly typed DataContext class references a strongly typed table, Contact, which has not been
created yet. The following code does that. Add it below the strongly typed DataContext class:
[Table(Name = "Person.Contact")]
public class Contact
{
[Column(DBType = "int not null")]
public int ContactID;
222
Chapter 11: LINQ to SQL Queries
[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;
[Column(DBType = "int")]
public int EmailPromotion;
[Column(DBType = "bit")]
public byte NameStyle;
[Column(DBType = "varchar(40)")]
public string PasswordHash;
[Column(DBType = "varchar(40)")]
public string PasswordSalt;
}
Next, add the following code to the Click event of the Insert button:
try
{
AdventureWorks db = new AdventureWorks("Integrated Security=sspi");
Contact con = new Contact();
con.


Pages:
341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365
hotel jelenia góra Russian bride Free English grammar and study guid powiekszenia wielkoformatowe counter strike 1.6