我不确定我是否真的在使用我的查询帮助Breeze,但是我要返回大约1500条记录,以便在需要过滤的树视图插件中使用。我正在创建一个自定义查询来执行此操作,以便我的后处理创建树节点尽可能高效。
由于我正在为我的查询挑选字段,因此我理解Breeze无法将每条记录识别为特定类型,因此我可以通过某种方式定义Breeze可以访问的视图或类,这将定义我的退回记录并削减了开销?
目前有1500手:
$type: "VB$AnonymousType_3`8[[System.String, mscorlib],[System.String, mscorlib],[System.Int32, mscorlib],[System.Boolean, mscorlib],[System.String, mscorlib],[System.String, mscorlib],[System.String, mscorlib],[System.String, mscorlib]], PKL2"`
正在增加很多开销!
我的查询:
Dim matquery = (From g In dc.Groups
Where g.IncludeInTree = True
Select New With {
.key = "f_" + CStr(g.Id),
.title = g.GroupDesc,
.isFolder = 1,
.isCompetitor = False,
.g1 = g.Group1,
.g2 = g.Group2,
.g3 = g.Group3,
.g4 = g.Group4
}).Union(From av In dc.ArticleVersions
Join g2 In dc.Groups On g2.Id Equals av.GroupId
Where av.IsDeleted = False
Select New With {
.key = "a_" + CStr(av.ID),
.title = av.ArticleCode,
.isFolder = 0,
.isCompetitor = av.IsCompetitorArticle,
.g1 = g2.Group1,
.g2 = g2.Group2,
.g3 = g2.Group3,
.g4 = g2.Group4
}).OrderBy(Function(x) x.g1).ThenBy(Function(x) x.g2).ThenBy(Function(x) x.g3).ThenBy(Function(x) x.g4).ThenByDescending(Function(x) x.isFolder).ThenBy(Function(x) x.title)
Return matquery
...以及返回数据的示例:
{
$id: "1093",
$type: "VB$AnonymousType_3`8[[System.String, mscorlib],[System.String, mscorlib],[System.Int32, mscorlib],[System.Boolean, mscorlib],[System.String, mscorlib],[System.String, mscorlib],[System.String, mscorlib],[System.String, mscorlib]], PKL2",
key: "a_1100",
title: "V31-607356",
isFolder: 0,
isCompetitor: false,
g1: "2",
g2: "25",
g3: "255",
g4: "2551"
},
{
$id: "1094",
$type: "VB$AnonymousType_3`8[[System.String, mscorlib],[System.String, mscorlib],[System.Int32, mscorlib],[System.Boolean, mscorlib],[System.String, mscorlib],[System.String, mscorlib],[System.String, mscorlib],[System.String, mscorlib]], PKL2",
key: "a_1101",
title: "V31-607361",
isFolder: 0,
isCompetitor: false,
g1: "2",
g2: "25",
g3: "255",
g4: "2551"
},
{
$id: "1095",
$type: "VB$AnonymousType_3`8[[System.String, mscorlib],[System.String, mscorlib],[System.Int32, mscorlib],[System.Boolean, mscorlib],[System.String, mscorlib],[System.String, mscorlib],[System.String, mscorlib],[System.String, mscorlib]], PKL2",
key: "f_268",
title: "Cups, plastic, printed",
isFolder: 1,
isCompetitor: false,
g1: "2",
g2: "25",
g3: "255",
g4: "2552"
}, ...
返回的类型目前是一个匿名/自定义类型,但我很乐意创建一个类/视图,如果这有助于微风?
答案 0 :(得分:2)
答案是,我可以!
添加:
Public Class treeItem
Public key As String
Public title As String
Public isFolder As Boolean
Public isCompetitor As Boolean
Public g1 As String
Public g2 As String
Public g3 As String
Public g4 As String
End Class
到我的代码并将select更改为Select New treeitem With {...
,立即将返回更改为:
$type: "PDK2.treeItem, PKL2"
...并且返回的数据大小减半 -