【发布时间】:2017-05-11 18:09:15
【问题描述】:
1.) 是否可以在 LINQ 中执行 DISTINCT 查询?类似于下面的 AQL 查询?
FOR cfg IN test_configuration
FOR method IN inspection_method
FILTER cfg.inspection_method_id == method._id
SORT method.name
RETURN DISTINCT method
2.) 是否可以执行“LET doc = DOCUMENT(some._id)”?我尝试了类似下面的查询,但得到了关于 Document not being supported 的异常。
from user in users
let dept = db.Document<Department>(user.department_id)
where dept.name == "lingerie"
select user
3.) 如何使用绑定参数执行原始 AQL 查询?我尝试了 CreateStatement(),但无法让它进行参数替换('evts' 是一个带有一些文档 ID 的 IEnumerable)。
List<ArangoDB.Client.Data.QueryParameter> parameters = new List<ArangoDB.Client.Data.QueryParameter>() {
new ArangoDB.Client.Data.QueryParameter() {
Name = "@P1",
Value = evts,
},
};
query = Database.CreateStatement<InspectionMethod>(@"
FOR cfg IN test_configuration
FOR method IN inspection_method
FILTER cfg.inspection_method_id == method._id AND cfg.test_event_id IN @P1
SORT method.name
RETURN DISTINCT method", parameters)
.AsEnumerable().AsQueryable();
调试输出:
==============================
5/11/2017 2:02:54 PM
creating an AQL query:
query:
FOR cfg IN test_configuration
FOR method IN inspection_method
FILTER cfg.inspection_method_id == method._id AND cfg.test_event_id IN @P1
SORT method.name
RETURN DISTINCT method
bindVars:
name: @P1 value: ["test_event/7250917"]
parsed query with variables replaced:
FOR cfg IN test_configuration
FOR method IN inspection_method
FILTER cfg.inspection_method_id == method._id AND cfg.test_event_id IN @P1
SORT method.name
RETURN DISTINCT method
【问题讨论】: