In trying to retrieve info from my database using linq but it won't work. When i excecute the code it throws the exception "'Unable to cast the type 'System.Guid' to type 'System.Object'. LINQ to Entities only supports casting EDM primitive or enumeration types.'
Public Class HomeTree
Inherits ApplicationFolders
Private _CanList As Boolean
Public Property CanList() As Boolean
Get
Return _CanList
End Get
Set(value As Boolean)
_CanList = value
End Set
End Property
Private _CanEdit As Boolean
Public Property CanEdit() As Boolean
Get
Return _CanEdit
End Get
Set(value As Boolean)
_CanEdit = value
End Set
End Property
Private _CanAdd As Boolean
Public Property CanAdd() As Boolean
Get
Return _CanAdd
End Get
Set(value As Boolean)
_CanAdd = value
End Set
End Property
Private _CanDelete As Boolean
Public Property CanDelete() As Boolean
Get
Return _CanDelete
End Get
Set(value As Boolean)
_CanDelete = value
End Set
End Property
Public Sub New()
End Sub
End Class
Retrieving Data
Dim GBItems As List(Of HomeTree) = (From t In db.ApplicationFolders
Join r In db.AppFolderRoleConfig On {t.AppFolderId, isLoggedInUser.ID_Role} Equals {r.AppFolderID, r.RoleID}
Where t.ParentID = 0 AndAlso t.TypeID = 1 Select New HomeTree With {
.ID_Key = t.ID_Key,
.AppFolderId = t.AppFolderId,
.Name = t.Name,
.Active = t.Active,
.Description = t.Description,
.ParentID = t.ParentID,
.TypeID = t.TypeID,
.CanAdd = r.CanAdd,
.CanDelete = r.CanDelete,
.CanEdit = r.CanEdit,
.CanList = r.CanList
}).ToList()
Ive tried googling for my issue but i cannot figure it out.
try this query example. since i dont know your db structure (was not provided) and data example i assumed on my own. i think this is what are you looking for
code
add image to prove that code is works