This is a migrated thread and some comments may be shown as answers.

Nullable input paramters

3 Answers 41 Views
Development (API, general questions)
This is a migrated thread and some comments may be shown as answers.
This question is locked. New answers and comments are not allowed.
Romain
Top achievements
Rank 1
Romain asked on 16 Oct 2013, 03:43 PM
Hi guys, 

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

CREATE PROCEDURE `P_S_TEST`(
    TEST1 INT ,
    TEST2 VARCHAR(36),
    TEST3 VARCHAR(32)
    )
BEGIN
    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.

3 Answers, 1 is accepted

Sort by
0
Romain
Top achievements
Rank 1
answered on 21 Oct 2013, 07:54 AM
Any idea/help ???
0
Kristian Nikolov
Telerik team
answered on 21 Oct 2013, 03:06 PM
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.

Regards,
Kristian Nikolov
Telerik
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 >>
0
Romain
Top achievements
Rank 1
answered on 23 Oct 2013, 10:01 AM
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 :)
Tags
Development (API, general questions)
Asked by
Romain
Top achievements
Rank 1
Answers by
Romain
Top achievements
Rank 1
Kristian Nikolov
Telerik team
Share this question
or