This repository was archived by the owner on Apr 11, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 91
Expand file tree
/
Copy pathQuery.js
More file actions
54 lines (45 loc) · 1.78 KB
/
Query.js
File metadata and controls
54 lines (45 loc) · 1.78 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
import $data, { $C, Guard, Container, Exception } from '../TypeSystem/index.js';
$C('$data.Query', null, null,
{
constructor: function (expression, defaultType, context) {
///<param name="context" type="$data.EntityContext" />
///<field name="expression" type="$data.Expressions.ExpressionNode" />
///<field name="context" type="$data.EntityContext" />
this.expression = expression;
this.context = context;
//TODO: expressions get as JSON string?!
this.expressions = expression;
this.defaultType = defaultType;
this.result = [];
this.rawDataList = [];
this.modelBinderConfig = {};
this.context = context;
},
rawDataList: { dataType: "Array" },
result: { dataType: "Array" },
resultType: {},
buildResultSet: function (ctx) {
var converter = new $data.ModelBinder(this.context);
this.result = converter.call(this.rawDataList, this.modelBinderConfig);
return;
},
getEntitySets: function(){
var ret = [];
var ctx = this.context;
var fn = function(expression){
if (expression instanceof $data.Expressions.EntitySetExpression){
if (ctx._entitySetReferences[expression.elementType.name] && ret.indexOf(ctx._entitySetReferences[expression.elementType.name]) < 0)
ret.push(ctx._entitySetReferences[expression.elementType.name]);
}
if (expression.source) fn(expression.source);
if (expression.members) {
for (var i = 0; i < expression.members.length; i++) {
fn(expression.members[i].expression);
}
}
};
fn(this.expression);
return ret;
}
}, null);
export default $data