Per Chapter 14, page 516 instructions, I have inserted the following code below into the ManagePhotoAlbum code-behind file. I am getting red, squiggly lines under the bold parts of this code.:
Code:
Public Function ListView1_GetData(<QueryString("PhotoAlbumId")> photoAlbumId As Integer) As IQueryable
Dim myEntities As New PlanetWroxEntities()
Return From p In myEntities.Pictures
Where p.PhotoAlbumId = photoAlbumId
Select p
End Function
Public Sub ListView1_InsertItem(<QueryString("PhotoAlbumId")> photoAlbumId As Integer)
Dim picture As New Picture()
TryUpdateModel(picture)
If ModelState.IsValid Then
Using myEntities As New PlanetWroxEntities
picture.PhotoAlbumId = photoAlbumId
myEntities.Pictures.Add(picture)
myEntities.SaveChanges()
End Using
End If
End Sub
These are the following errors:
QueryString: Type 'QueryString' is not defined.
TryUpdateModel: 'TryUpdateModel' is not declared. It may be inaccessible due to its protected level.
ModelState: 'ModelState' is not declared. It may be inaccessible due to its protected level.
When I attempt to run the app, I get the following error:
Quote:
A null value for parameter 'photoAlbumId' of non-nullable type 'System.Int32' for method 'System.Linq.IQueryable ListView1_GetData(Int32)' in '_ManagePhotoAlbum'. An optional parameter must be a reference type or a nullable type.
Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.
Exception Details: System.InvalidOperationException: A null value for parameter 'photoAlbumId' of non-nullable type 'System.Int32' for method 'System.Linq.IQueryable ListView1_GetData(Int32)' in '_ManagePhotoAlbum'. An optional parameter must be a reference type or a nullable type.
|