Jeff-Lewis / codesmith

Automatically exported from code.google.com/p/codesmith
0 stars 0 forks source link

PLINQO: Add @ for stored procedures parameters #102

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
Please add @ for generation of parameters for stored procedures as they can
have names like fixed which is reserved word in c#

Original issue reported on code.google.com by kachalkov on 14 May 2009 at 3:23

GoogleCodeExporter commented 9 years ago
[deleted comment]
GoogleCodeExporter commented 9 years ago
like this:

ing GetArguments(Function function)
    {
        StringBuilder s = new StringBuilder();

        for(int x = 0; x < function.Parameters.Count; x++)
        {
            Parameter p = function.Parameters[x];
            s.AppendLine();
            s.AppendFormat("            [Parameter(DbType=\"{0}\")] ", p.DbType);

            if (p.Direction != LinqToSqlShared.DbmlObjectModel.ParameterDirection.In)
                s.Append("ref ");

            s.AppendFormat("{0} @{1}",GetParameterType(p), p.ParameterName);

            if (x < function.Parameters.Count - 1)
                s.Append(", ");
        }

        return s.ToString();
    }

    public string GetParameterType(Parameter p)
    {
        if (CommonUtility.IsNullableType(p.Type))
            return CSharpAlias[p.Type] + "?";
        else
            return CSharpAlias[p.Type];
    }

    public string GetArgumentNames(Function function)
    {
        StringBuilder s = new StringBuilder();

        for(int x = 0; x < function.Parameters.Count; x++)
        {
            if (x < function.Parameters.Count)
                s.Append(", ");

            Parameter p = function.Parameters[x];
            s.AppendFormat("@{0}", p.ParameterName);
        }

        return s.ToString();
    }

Original comment by kachalkov on 14 May 2009 at 5:07

GoogleCodeExporter commented 9 years ago

Original comment by shannon....@gmail.com on 15 May 2009 at 7:10

GoogleCodeExporter commented 9 years ago
fixed this bug.  thanks for reporting.

Original comment by paul.wel...@gmail.com on 18 May 2009 at 5:39