Example #1
0
        protected override Expression VisitMemberInit(MemberInitExpression node)
        {
            for (var bindingIndex = 0; bindingIndex < node.Bindings.Count; bindingIndex++)
            {
                var initExpressionBinding = node.Bindings[bindingIndex];
                if (initExpressionBinding.BindingType != MemberBindingType.Assignment)
                {
                    throw new NotSupportedException();
                }

                var memberAssignment = (MemberAssignment)initExpressionBinding;

                if (bindingIndex != 0)
                {
                    _statementBuilder.Append(",");
                    _statementBuilder.AppendLine();
                }

                var relationalPropertyAnnotations = _entityType.FindProperty(memberAssignment.Member.Name).Relational();

                var columnName = relationalPropertyAnnotations.ColumnName;
                _currentAssignmentColumnType = relationalPropertyAnnotations.ColumnType;

                _statementBuilder.Append("    ");
                _statementBuilder.DelimitIdentifier(columnName);
                _statementBuilder.Append(" = ");

                Visit(memberAssignment.Expression);
            }

            return(node);
        }