I am struggling with Linq to Entites. I am new to EF5 and Linq. I am programming in VB.NET. I have been using Table Adapters that return DataSets as the DAL into a BLL that I then linked to ObjectDataSource. Now I upgraded to VS2012 from VS2005 ASP.NET 2.0 to ASO,.NET 4.0 to use EF5 and I have setup EF5 as the DAL and I am trying to rewrite the BAL to use the Linq to Entities to go to the ObjectDataSource. I can do some complex queries over multiple tables using the Navigation I setup with Foreign keys but I don't understand how to get the return type to work with the ObjectDataSource which expects a DataSet.
ContentQ = From ct In DAL.Contents, cd In ct.ContentDuplicateTypes, ce In ct.ContentEditors _
Where ct.ContentId = Contentid And cd.ShowOnWeb = ShowOnWeb And cd.Hide = Hide And ce.UserId = UserId And ct.websiteId = websiteid Select ct, cd, ce
For returning a single table for example ContentQ= From ct in DAL.Contents select ct
Why does this work below? Why do I have to populate this class to get it into the ObjectDataSource with a 1-to-many of 2 tables using the include method?
<System.ComponentModel.DataObjectMethodAttribute(ComponentModel.DataObjectMethodType.Select, True)> _
Public Function GetContentFiles() As ContentData
Dim objContentData As New ContentData
Using _SBEF As New SBEF5
Dim objContentDuplicateType = From d In _SBEF.ContentDuplicateTypes.Include("Content") Select d
For Each objQuery In objContentDuplicateType.ToList
With objContentData
'Content
.Description = objQuery.Content.Description
.FileName = objQuery.Content.FileName
.Draft_Path = objQuery.Content.Draft_Path
.Live_Path = objQuery.Content.Live_Path
.HeaderTitle = objQuery.Content.HeaderTitle
'ContentDuplicateType
.ContentId = objQuery.ContentId
.DisplayHeader = objQuery.DisplayHeader
.OrderNumber = objQuery.OrderNumber
.ShowOnWeb = objQuery.ShowOnWeb
.Hide = objQuery.Hide
.DateCreated = objQuery.DateCreated
.ContentTypeID = objQuery.ContentTypeId
End With
Next
GetContentFiles = objContentData
End Using
End Function