Errata

MCTS Self-Paced Training Kit (Exam 70-516): Accessing Data with Microsoft .NET Framework 4

Errata for MCTS Self-Paced Training Kit (Exam 70-516): Accessing Data with Microsoft .NET Framework 4

The errata list is a list of errors and their corrections that were found after the product was released.

The following errata were submitted by our customers and have not yet been approved or disproved by the author or editor. They solely represent the opinion of the customer.

Color Key: Serious technical mistake Minor technical mistake Language or formatting error Typo Question Note Update

Version Location Description Submitted by Date submitted
Printed Page 57
Instruction #14

Instruction #14 says to run the application, and shows Figure 1-9 with an example of what my screen should look like. I should be able to add vehicles, etc. When I run the application, including running the completed solution that comes on the disc, I just get a form showing the two blank DataGridViews. Is there a step missing? Again the same thing happens when I run the completed solution that comes on the disc.

Adrian Pountney  Mar 18, 2013 
Printed Page 113
Near middle

For the cmdDeleteRepairs.Parameters.Add for @OriginalDescription, the length should be 60 not 20.

This is similar to a previous post regarding the cmdUpdateRepairs.

Philip Brown  Jul 02, 2013 
Printed Page 246
3rd paragraph

In the paragraph that starts with 'The property getter isn't doing...'

it has 'OnCustomerIDChanging and OnCustomerChanged methods'.

The 2nd method should be OnCustomerIDChanged, not OnCustomerChanged.

Philip Brown  Jul 18, 2013 
Printed Page 383
Middle of page

Regarding while lazy loading is True, and the paragraph near the middle saying:

'In this example, the order detail objects were not retrieved until the ToList method was executed.'

I did a similar test (lazy loading = true) using:

dg1.ItemsSource = (from p in db.People
select p).ToList();

That cause an ObjectDisposedException. According to the MSDN link here

http://msdn.microsoft.com/en-us/library/system.data.objects.objectcontext.connection.aspx

the lazy loading occurs when a navigation method is used. So I changed my test to:

dg1.ItemsSource = (from p in db.People
select p.StudentGrades).ToList();

And now it works! So the part in middle of page 383 that says

'In this example, the order detail objects were not retrieved until the ToList method was executed.'

should mention how the navigation method (Order_Details in the book example) is crucial. This may seem minor, but it is nice to know how to avoid ObjectDisposedExceptions while lazy loading is true.

Philip Brown  Aug 02, 2013 
Printed Page 390
Example at top of page

This regards the example code which uses a custom property 'od.DetailTotal'.

When I tried this I got the error 'The specified member DetailTotal' is not supported in LINQ to Entities. Only initializers, entity members, and entity navigation can ... etc.

So I did some research and found a forum link called "EF4 CTP4 Code First - The specified type member 'Total' is not supported in LINQ to Entities" which explained how:

The issue is that the EF LINQ Provider will take the query you write and convert it into to SQL that then runs against the database. Because the logic for calculating your custom property is only defined in code, EF has no way to know how to translate this into SQL. So need to write the query to pull the orders and details into memory so that you can use your custom property then.

Below is what worked for me. Note, I could not use the navigation method od.Order.CustomerID (like on p. 390) as 'Order' was always null for some reason, so I used a different method to get the orders.

// Execute SQL DB query now
var OrderDetails = (from o in db.Orders
where o.CustomerID == mSelectedCustomerID
join od in db.Order_Details
on o.OrderID equals od.OrderID
select od).ToList();

// Now we can use our custom property via in-memory collection:
dg1.ItemsSource = from od in OrderDetails
select new
{
od.OrderID,
od.ProductID,
od.Quantity,
od.Discount,
TotalPrice = od.DetailTotal.ToString("c") // our custom property
};

Philip Brown  Jul 31, 2013 
Printed Page 392
Figure 6-12 at top of page

Regarding Figure 6-12 which shows the Vehicles table, it would be nice to describe how to pull up this display. I finally figured out this can be done via Server Explorer / Expand your DB connection / expand Tables / Right click the table of interest / Open Table Definition.

Philip Brown  Aug 01, 2013 
Printed Page 423
Paragraph about Sorting

Reverse() does not appear to be supported by EF, though the text claims otherwise.

Paul Taylor  Apr 25, 2013 
Printed Page 472
Middle of page

Regarding 'You can also use the $value keyword to retrieve the raw value...although $value is implied if you don't specify it.

Actually, there is a difference.

http://localhost:56943/NorthwindService.svc/Customers('QUICK')/CompanyName

returns:

<?xml version="1.0" encoding="UTF-8" standalone="true"?>
<CompanyName xmlns="http://schemas.microsoft.com/ado/2007/08/dataservices">QUICK-Stop</CompanyName>

But
http://localhost:56943/NorthwindService.svc/Customers('QUICK')/CompanyName/$value

returns:

QUICK-Stop

Philip Brown  Aug 15, 2013