linq UnionAll 报错
本帖最后由 tinqiu 于 2013-07-12 10:25:12 编辑 Imports Microsoft.Office.Tools.Ribbon
Imports System.Linq
Imports System.Data.Entity
Imports System.Data.Objects
Imports System.Data
Imports System.Collections.Generic
Dim Entities As New MyDbEntities1()
Dim econtext As ObjectContext = New ObjectContext("name = MyDbEntities1")
Dim query As ObjectQuery(Of 销售产品清单) = econtext.CreateObjectSet(Of 销售产品清单)()
Dim query1 As ObjectQuery(Of 销售产品清单_一对多对应) = econtext.CreateObjectSet(Of 销售产品清单_一对多对应)()
Dim query3 As ObjectQuery = query.UnionAll(query1)
红字报错,提示:错误 3 类型“System.Data.Objects.ObjectQuery(Of ExcelAddIn2.销售产品清单_一对多对应)”的值无法转换为“System.Data.Objects.ObjectQuery(Of ExcelAddIn2.销售产品清单)”。 F:\My Documents\Documents\Visual Studio 2012\Projects\ExcelAddIn2\ExcelAddIn2\Ribbon1.vb 128 52 ExcelAddIn2
linq刚学,请帮忙看看,谢谢!
[解决办法]
Dim query1 As ObjectQuery(Of 销售产品清单_一对多对应) = econtext.CreateObjectSet(Of 销售产品清单_一对多对应)()
query1=query1.Select(Function(q) New 销售产品清单{/* 这里转换*/})