Welcome to Bucaro TecHelp!

Bucaro TecHelp
HTTPS Encryption not required because no account numbers or
personal information is ever requested or accepted by this site

About Bucaro TecHelp About BTH User Agreement User Agreement Privacy Policy Privacy Site Map Site Map Contact Bucaro TecHelp Contact RSS News Feeds News Feeds

Language Integrated Queries (LINQ) and Visual Basic

The SQL language, used to manipulate Microsoft SQL Server data, was developed in 1974 and is showing its age. SQL has been continually extended. And as the SQL language has grown - so have the complexities.

LINQ is a better version of SQL - it is a part of ADO.NET and is integrated with VB.NET. It automatically maps the different data types of Visual Basic and SQL Server. LINQ now has the long missing option of using Visual Basic functionality in the data selection process.

LINQ provides statement completion, auto correction and IntelliSense. LINQ enables compile-time validation of queries so that bugs are caught before code execution. Strongly typed data provides greater reliability, fewer mistakes, easier debugging and faster development. LINQ creates code that is easy to understand and maintain.

There are many variations of LINQ - LINQ to Entities, LINQ to XML, and LINQ to Objects.

The Features of LINQ to Entities

LINQ will optimise the code at compile and run-time
A LINQ query can be bound to any List, Grid or Combo Box Control
Fields are no longer treated as Objects - they now have full Type checking
Queries can be easily iterated
LINQ can handle all the SQL options, like Filtering, Sorting, Grouping, Totalling, Min, Max, etc.
LINQ has a more natural syntax than SQL to query and update a database
LINQ simplifies query logic - no more complex Foreign Key Joins
The logic for Adds, Deletes and Updates is much simpler than with ADO.Net
LINQ uses Lazy Loading to initialise and use objects only when needed
The underlying SQL query can be extracted from the LINQ query

But:

LINQ to Entities does not perform as well as ADO.Net - yet
LINQ to Entities is immature
Complex queries loose strong typing - all fields become strings
Error handling is primitive

These deficiencies are improved in VS2012.

The Learning Curve

Learning about LINQ is not easy - there are very few books on LINQ 2010 using Visual Basic. The Internet has mainly irrelevant documentation that show out-dated examples. And trying to make sense of complex C# examples is just a waste of time.

The Visual Basic coding for LINQ, when one eventually gets down to it, has been very much simplified. This is due mainly to the Visual Basic "Option Infer" Type inference which eliminates Object Oriented complexities.

Partial Classes

LINQ to Entities uses partial classes and methods to allow update, validation and Business logic to be easily added in separate code modules. The logic of the Partial Class can be encapsulated in a Business Library.

The 3-Tier Architecture layers can still be split between a Presentation Tier, a Business Logic Tier (using a VB.Net Class Library) and a Data Tier (using LINQ). But all the logic takes place on the Client - the Server only handles Database processing.

From the IT Manager's perspective

LINQ can significantly reduce Database development time
LINQ prevents SQL injection attacks with Client compile-time safety
LINQ is easier to maintain and debug - problems are picked up at compile-time
There are fewer complexities with the LINQ syntax than with SQL and Stored Procedures

RSS Feed RSS Feed

Follow Stephen Bucaro Follow @Stephen Bucaro

Fire HD
[Site User Agreement] [Privacy Policy] [Site map] [Search This Site] [Contact Form]
Copyright©2001-2024 Bucaro TecHelp 13771 N Fountain Hills Blvd Suite 114-248 Fountain Hills, AZ 85268