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

Needed Boolean support. #21

Open
onyamegatron opened this issue Feb 12, 2024 · 0 comments
Open

Needed Boolean support. #21

onyamegatron opened this issue Feb 12, 2024 · 0 comments

Comments

@onyamegatron
Copy link

onyamegatron commented Feb 12, 2024

Hi there I have been pained by these drivers lack of proper support for booleans. Whether it is querying the db or inserting an entry with a boolean.
For example
BoolHolder foo = new BoolHolder {test = true, id = 1};

`

        var context = GetContext(session);
        using (IDbContextTransaction transaction = context.Database.BeginTransaction())
        {
            try
            {
                context.Entry(foo).State = EntityState.Added;
                await context.SaveChangesAsync();
                await transaction.CommitAsync();
            }
            catch (Exception ex)
            {
                transaction.Rollback();
                Console.WriteLine("Error occurred.");
            }
        }`

This will be added to my database with the boolean being randomly assigned a false or true value.
A simple workaround is doing something like
(EDIT: THIS ACTUALLY DOESNT FIX IT SAME ISSUE OCCURS WHEN USING PARAMETERIZED UPDATEDS W/ RAWSQL)

`

        var context = GetContext(session);
        using (IDbContextTransaction transaction = context.Database.BeginTransaction())
        {
            try
            {
                context.Entry(foo).State = EntityState.Added;
                await context.SaveChangesAsync();
                await transaction.CommitAsync();
                await context.Database.ExecuteSqlRawAsync("UPDATE Boolholder SET test = @p0 WHERE id = @p1", foo.test, foo.id);
            }
            catch (Exception ex)
            {
                transaction.Rollback();
                Console.WriteLine("Error occurred.");
            }
        }`

And that seems to work fine however this problem is even more of a headache when trying to retrieve data. Trying to query something based on a boolean just straight up does not work. You'd have to workaround it by switching flags to another datatype
Cheers

EDIT: SEE PHOTO BELOW NOT EVEN RAWSQL WORKS WITH PARAMETERISED VALUES ONLY HARD TYPING BOOL VALUES WORK ?????????

Console.WriteLine($"Pickup : {order.Pickup}");
Console.WriteLine($"Pickup : {order.MultiPay}");
await context.Database.ExecuteSqlRawAsync("UPDATE OrderHdr SET Pickup = @p0, Multi_Pay = @p1 WHERE Order_Id = @p2", order.Pickup, order.MultiPay, order.OrderId);
image

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

No branches or pull requests

1 participant