Method
executeQuery(_:arguments:)
Executes a query and returns its result.
@MainActor func executeQuery(_ query: MTLQuery, arguments: [(any EcoreValue)?]) async throws -> (any EcoreValue)?
Parameters
query-
The query to execute
arguments-
The arguments matching the query parameters
Return Value
The query result, or nil if the result is null
Discussion
Queries are side-effect-free operations that compute values from model elements without generating text output.
Example
let query = MTLQuery(
name: "isPublic",
parameters: [MTLVariable(name: "element", type: "Element")],
returnType: "Boolean",
body: MTLExpression(/* element.visibility = 'public' */)
)
let result = try await generator.executeQuery(query, arguments: [element])
if let isPublic = result as? Bool, isPublic {
print("Element is public")
}