内部加入实体框架 - 如何?

时间:2017-01-19 06:37:46

标签: sql asp.net vb.net entity-framework-5

我是Entity Framework的新手,我有这个SQL查询:

SELECT        
    WarningTypes.WarningTypeID, WarningTypes.WarningDescription, 
    WarningTypes.WarningArDescription, WarningReasons.ReasonName
FROM            
    WarningTypes 
INNER JOIN
    WarningReasons ON WarningTypes.WarningReasonID = WarningReasons.ID

我需要将其转换为实体框架工作,所以我写了这个vb.net代码:

Public Function selectAllWarningTypes() As System.Linq.IQueryable
            'Dim dt As New DataTable
            'wt.selectAllWarningTypes(dt)

            Dim query = _
                        From warningTypes In objSRSEntities.WarningTypes _
                        From warningReasons In objSRSEntities.WarningReasons _
                        .Where(Function(wr) wr.ID = warningTypes.WarningReasonID) _
                        Select warningTypes = warningTypes, warningReasons = warningReasons
            Return query


        End Function

问题是:当我在gridview中设置结果时返回此运行时错误:

  

不支持直接绑定到商店查询(DbSet,DbQuery,DbSqlQuery,DbRawSqlQuery)的数据

感谢。

0 个答案:

没有答案