Dapper.net Oracle parameter

后端 未结 1 1374
面向向阳花
面向向阳花 2021-01-12 05:13

I am trying to use Dapper.net with Oracle.

From this post i understood that we could use parameters with no prefixes and dapper would then work for both sql se

相关标签:
1条回答
  • 2021-01-12 05:42

    Yes, you misunderstood the post. The SQL is passed through as-is, and must contain the correct :param1 or @param1 etc. The "no prefix at all" is talking about the code that you don't see - specifically, making sure that the code does (via some mechanism):

    cmd.Parameters.Add("param1", 963);
    

    vs

    cmd.Parameters.Add("@param1", 963);
    

    vs

    cmd.Parameters.Add(":param1", 963);
    

    The first (no prefix) is the correct and preferred option.

    If you want the SQL in your code to be parameter agnostic, you could use the information from here: Get the parameter prefix in ADO.NET

    The SQL is rarely close enough, however, that just looking up the parameter prefix will fix all problems.

    0 讨论(0)
提交回复
热议问题