July 2015
Intermediate to advanced
1300 pages
87h 27m
English
LINQ to SQL also allows writing SQL code against entities so that you can still take advantage of the object model if you prefer the old-fashioned way of manipulating data. The DataContext class offers an instance method named ExecuteQuery(Of T) that allows sending SQL instructions in string form. For example, the following code retrieves a list of products for the Grain/Cereals category, ordered by product name:
Sub DirectSqlDemo() Dim products = northwind. ExecuteQuery(Of Product)("SELECT * FROM PRODUCTS WHERE " & _ "CATEGORYID='5' ORDER BY PRODUCTNAME") For Each prod In products Console.WriteLine(prod.ProductName) NextEnd ...
Read now
Unlock full access