Contact WHERE ContactID > 19990
309
Part III: LINQ to SQL
Figure 15-23
Awesome. But wait, it gets better. Stop the project and modify the code in the Load() method of the form,
so that it looks like the following:
private void Form1_Load(object sender, EventArgs e)
{
var conQuery =
from con in db.Contacts
select con;
contactBindingSource.BindingSource = conQuery;
}
This illustrates that you can also bind a BindingSource directly to a LINQ to SQL query.
Summary
This chapter explored the Visual Studio O/R Designer and the associated SqlMetal utility. Each of these
provide a great service in that you can quickly and easily create and manage LINQ to SQL classes, their
associated relationships, and mappings. The purpose of doing things manually to begin with was to help
lay the foundation and show how things are created, so that when an entity is created, you know what is
going on behind the scenes.
This chapter also discussed external mappings with your object model. As stated earlier, external mapping
provides the benefit of being able to separate the mapping code from the application code.
Pages:
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489