17.06.2013 Views

Beginning Microsoft SQL Server 2008 ... - S3 Tech Training

Beginning Microsoft SQL Server 2008 ... - S3 Tech Training

Beginning Microsoft SQL Server 2008 ... - S3 Tech Training

SHOW MORE
SHOW LESS

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

Appendix B: Very Simple Connectivity Examples<br />

656<br />

A full discussion of LINQ is well beyond the scope of this book, and the query syntax is different enough<br />

that I am going to avoid confusing the beginner here with the new twist on things. That said, it is worth<br />

noting some things about what LINQ is and isn’t.<br />

LINQ uses a strongly typed model to allow queries to a wide variety of data. While access to <strong>SQL</strong> <strong>Server</strong><br />

is what is most relevant to this book, it’s important to note that LINQ is very capable of connectivity<br />

with non-tabular data sources. LINQ can be used to access XML (XPath is generally the better choice,<br />

but you may want to use LINQ for consistency with other data access you’re doing), and it can be used<br />

to access things such as object collections. In short, it is wildly flexible about what kind of data it is<br />

returning.<br />

Beyond the flexibility, the primary advantage I see to LINQ is that it is strongly typed. Previous access<br />

models used a binding model where your program didn’t really have any assurances of what data type<br />

it was getting back until runtime. LINQ utilizes a far more early binding to the data, and therefore is<br />

able to catch many types of type mismatch or similar errors earlier in the coding process. This is, of<br />

course, not entirely foolproof, but it is an advance in terms of the particular area it is addressing.<br />

If you’re thinking that you’re going to use LINQ for all your data access, all I can do is to encourage you<br />

to make sure that you understand why LINQ is your choice prior to making it. Don’t use it because it’s<br />

the latest “cool” thing, but rather because it fits your particular need better than the other options available<br />

to you.

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!