예제 #1
0
        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))),
            });
        }
예제 #2
0
 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()));
 }