Nullable input paramters

Thread is closed for posting
4 posts, 0 answers
  1. Romain
    Romain avatar
    5 posts
    Member since:
    Sep 2013

    Posted 16 Oct 2013 Link to this post

    Hi guys, 

    For the second time, I need your help.
    As example, I have the following Mysql stored procedure

        TEST1 INT ,
        TEST2 VARCHAR(36),
        TEST3 VARCHAR(32)
        SELECT *
        FROM    t_tests tes
        WHERE   ((TEST1 IS NULL) OR (TEST1 IS NOT NULL AND tes.tes_id = TEST1 ))
        AND ((TEST2 IS NULL) OR (TEST2 IS NOT NULL AND tes.tes_nom = TEST2 ))
        AND     ((TEST3 IS NULL) OR (TEST3 IS NOT NULL AND tes.tes_prenom = TEST3 ))

    I want to use it in my C# code. Then, I added correctly (i think) this stored procedure in my model, and created a domain method.
    Nevertheless, when I add this stored procedure, I have a look on input parameters and I can see that nullable value is not authorized (false value).
    And the  generated code seems to apply this behavior as I have :

    public IEnumerable<CWI.DAL.TELERIK.MYSQL.P_S_TESTResultSet> P_S_TEST(int TEST1, string TEST2, string TEST3)

    IS there any solution so as to authorize null parameters for mysql procedures ?
    Is that possible to have an "int?" instead of this simple "int" as parameter in generated function ? 

    Thanks a lot for your help.

  2. Romain
    Romain avatar
    5 posts
    Member since:
    Sep 2013

    Posted 21 Oct 2013 Link to this post

    Any idea/help ???
  3. Kristian Nikolov
    Kristian Nikolov avatar
    206 posts

    Posted 21 Oct 2013 Link to this post

    Hi Romain,

    Since MySQL does not have optional parameters, OpenAccess ORM is unable to automatically determine whether it should use nullable arguments for the generated domain methods. Unfortunately, currently we do not provide an out of the box way to explicitly specify whether and which arguments of the generated domain method should be nullable.

    I have created a feature request for this functionality. Voting for it will help us to better prioritize it as compared with other features. Meanwhile, as a possible workaround, you may copy the code from the generated domain method and place it in the body of a method defined by you with nullable arguments. Afterwards you can delete the domain method from Model Object Explorer to prevent it from being generated. With this approach you will avoid possible unwanted calls to the originally generated domain method.

    I hope this helps.

    Kristian Nikolov
    OpenAccess ORM Q3 2013 Beta is available for immediate download in your account. Get it now and play with the latest bits. See what's new >>
  4. Romain
    Romain avatar
    5 posts
    Member since:
    Sep 2013

    Posted 23 Oct 2013 Link to this post

    Ok, I have done a copy of the generated procedure in file which is a partial class of the generated code. After that, I have managed null values as you do for strings, and deleted the method in the model. 

    Thanks for that replacement solution.

    Of course, I voted yes. I do not think it's hard dev :)
Back to Top