DateJS, OpenSource JavaScript Date Library Two interesting posts!
Dec 03

This is a series of posts regarding the new language improvements in VB 9. Bill Horst has written the second on which I came across here. As we all know VB LINQ statements enable SQL-like syntax for queries in the VB language. LINQ syntax doesn’t match SQL syntax exactly, so if you are already working with SQL or familiar with SQL queries, you may find yourself wanting to convert an existing SQL query to LINQ.

And here is an example with FROM clause:

A SQL SELECT statement always begins with a SELECT Clause, followed by a FROM Clause. A VB query expression always begins with a From Clause or Aggregate Clause (Aggregate will be discussed later). A basic SQL FROM clause specifies a table over which to query, and similarly, a LINQ From Clause specifies an object over which to query (CustomerTable). This object could represent “In-Memory” data, a SQL data table, or XML information. My examples use the “In-Memory” case, since it allows the simplest code. In addition to this data object, the VB From clause always includes an identifier for the current “row” (Contact), which basically functions as an alias.

SQL

SELECT Contact.CustomerID, Contact.Phone
FROM CustomerTable Contact

LINQ

From Contact In CustomerTable
Select Contact.CustomerID, Contact.Phone

Here is the whole post by Bill Horst.

In it training, the order of courses matters a lot. Doing 70-290 after 70-270 makes more sense rather than the vice versa. This holds true for 70-291 as well. A 642-901 should be attempted after 642 series, not something as basic as 70-297.

Related posts:

  1. Converting SQL to LINQ - DISTINCT, WHERE, ORDER BY and Operators
  2. Converting SQL to LINQ, Part 4: Functions
  3. LINQ to SQL (Part 3 - Querying our Database)
  4. Introducing LINQ – Part 1
  5. Using LINQ to SQL (Part 1)

2 Responses to “Converting SQL to LINQ”

  1. Converting SQL to LINQ - DISTINCT, WHERE, ORDER BY and Operators | Ajaxus place on the net Says:

    [...] Horst continues with those simple examples. After this one here comes the other set. They are perfect to show basic syntax. Here are few [...]

  2. churchill Says:

    pls i need your help on the conversion. converting sql to linq

    “Select * from cm_organizations Where org_id in (Select Org_id from cm_user_organization where logon_name=’” & UCase$(Session(”FullUserName”)) & “‘)”

Leave a Reply

TopOfBlogs