Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Explicit cast parameters #47

Open
SoftStoneDevelop opened this issue Aug 19, 2023 · 1 comment
Open

Explicit cast parameters #47

SoftStoneDevelop opened this issue Aug 19, 2023 · 1 comment
Assignees
Labels
CommonGenerator Applies to all supported providers
Milestone

Comments

@SoftStoneDevelop
Copy link
Owner

It's mostly useful for enums. When in the code it is Enum and in the database it is short for example.

Now:

        [Query(@"
UPDATE public.table_with_enum
SET
    status = $1
WHERE
    id = $2
;
",
            "SetStatus",
            methodType: MethodType.Async,
            sourceType: Gedaq.Npgsql.Enums.SourceType.Connection,
            queryType: QueryType.NonQuery,
            accessModifier: AccessModifier.Public
            ),
            Parametr(typeof(short), position: 1, methodParametrName: "status"),
            Parametr(typeof(long), position: 2, methodParametrName: "id")
            ]
        private void ConfigSetStatus()
        {
        }

        public SomeMethod()
        {
            await SetStatus(connection: connection, status: (short)CurrentStatus.New, id: 1);
        }

Excpect:

        [Query(@"
UPDATE public.table_with_enum
SET
    status = $1
WHERE
    id = $2
;
",
            "SetStatus",
            methodType: MethodType.Async,
            sourceType: Gedaq.Npgsql.Enums.SourceType.Connection,
            queryType: QueryType.NonQuery,
            accessModifier: AccessModifier.Public
            ),
            Parametr(typeof(short), position: 1, methodParametrName: "status", methodParametrType: typeof(CurrentStatus)),
            Parametr(typeof(long), position: 2, methodParametrName: "id")
            ]
        private void ConfigSetStatus()
        {
        }

        public SomeMethod()
        {
            await SetStatus(connection: connection, status: CurrentStatus.New, id: 1);
        }

Add methodParameterType optional parameter.

@SoftStoneDevelop
Copy link
Owner Author

Enumerations are quite common and writing a cast every time is quite tedious. It does not always make sense to add an implicit cast.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
CommonGenerator Applies to all supported providers
Projects
None yet
Development

No branches or pull requests

1 participant