Column Type bool

I have problems with the datatype bool type column.

I have a new fresh blazor server app.

Its runing with sql lite. No new entities.

Now in the admin-ui:

I first create a new booking with cancel true. Works!

Then I update booking ID and try to set it to cancel false.

Submit with no error.

But the data for the Cancelled Column is still true.

The same with every bool type column.
If you had set the value to true is not possible to switch it to false again.

With in memory database tables ( like in the sample app the todo entity) its works.

Alois

It’s because API Explorer forms only sends non empty values and doesn’t have the original record to compare it to determine if it’s dirty or not.

You can edit AutoQuery APIs with Locode whose edit form loads the current booking where it’s able to tell which fields are dirty:

https://blazor-vue.web-templates.io/locode/QueryBookings

What is the database behind the sample?
https://blazor-vue.web-templates.io/locode/QueryBookings

I work with SQL Lite and I tried to update the boolean column via service stack update.
Its not possible to set it to false if it was true before.

It’s the standard blazor-vue template with SQLite.

Are you using locode? i.e. /locode/ instead of API Explorer /ui/

FYI source code for both Blazor + Blazor Vue templates:

No, I make a api call like this

var api = await ApiAsync(new UpdateObjectUnit
{
Id = Id,
ObjectId = ObjectId,
Name = model.Name,
ManufacturerId = model.ManufacturerID,
Description = model.Description,
State = model.State,
Activ = model.Activ,
Sort=model.Sort,
Annex1 = model.Annex1,
Annex2 = model.Annex2,
Annex3 = model.Annex3,
Annex4 = model.Annex4,
Annex5 = model.Annex5,
Annex6 = model.Annex6,
Annex7 = model.Annex7,
Annex8 = model.Annex8,
ModifiedDate = DateTime.UtcNow,
ModifiedInfo = by
});
if (!api.Succeeded)
,

The Activ Column is boolean and its not possible to update it to false.

Every other column is save, no error.

It was possible to make the update to True but not to false.

If your UpdateObjectUnit DTO implements IPatchDb<Table> then it’s a partial update which only updates populated (i.e. non-default) values where all properties (other than the Primary Key) need to be optional/nullable.

If it isn’t, change your UpdateObjectUnit.Active property to:

public bool? Activ { get; set; }
1 Like

That’s work, thank you very much

1 Like