private static TypedParameterModel GetParameter(FunctionParameter functionParameter)
        {
            var declaration  = functionParameter.NameAndType;
            var defaultValue = functionParameter.DefaultValue;

            var(name, type) = declaration
                              .GetImmediateDescendants <SyntaxNode>()
                              .ExtractChildren <NameDeclaration, TypeExpression>("Parameter pair");

            if (type is PrimitiveTypeExpression)
            {
                var typeExpression = type as PrimitiveTypeExpression;

                return(new TypedParameterModel(
                           EntityName.FromCode(name),
                           typeExpression !.Type.ValueText,
                           defaultValue != null ? defaultValue.ToString() : null));
            }
            else
            {
                var typeExpression = type as SchemaTypeExpression;
                var cols           = typeExpression !.Columns;

                //  Consider the case T(*)
                if (cols.Count == 1 &&
                    cols.First().GetImmediateDescendants <NameAndTypeDeclaration>().Count == 0)
                {
                    return(new TypedParameterModel(
                               EntityName.FromCode(name),
                               new TableParameterModel(new TableColumn[0])));
                }
                else
                {
                    var columns = typeExpression !
                                  .Columns
                                  .Select(c => c.GetUniqueImmediateDescendant <NameAndTypeDeclaration>("Function parameter table column"))
                                  .Select(n => GetColumnSchema(n));
                    var table = new TableParameterModel(columns);

                    return(new TypedParameterModel(
                               EntityName.FromCode(name),
                               table));
                }
            }
        }
 public TypedParameterModel(EntityName parameterName, TableParameterModel tableSchema)
     : this(parameterName)
 {
     ComplexType = tableSchema;
 }