protected VisitResult VisitElementLiteral(ElementLiteralOperation operation) { var fields = operation.Fields.Select(field => Visit(field.Value).ResultSchema).ToList(); var schema = SchemaNode.GetSchemaNodeForElementLiteralOperation(operation, fields); Type objectType = _objectService.GetTypeForElement(schema, out var mappings); _schemaTypeMappings[schema] = mappings; return(new VisitResult { ResultSchema = schema, Expression = Expression.MemberInit( Expression.New(objectType.GetConstructor(new Type[0])), operation.Fields.Select(field => Expression.Bind(objectType.GetProperty(mappings.Get(field.Name)), Visit(field.Value).Expression))), }); }
public static SchemaNodeComplex GetSchemaNodeForElementLiteralOperation(ElementLiteralOperation operation, IEnumerable <SchemaNode> fieldSchemas) { return(new SchemaNodeComplex(operation.Fields.Zip(fieldSchemas, (operationField, schema) => new SchemaNodeComplexField(schema, operationField.Name, operationField.Name, "", true)).ToList())); }