Inline edit compound primary key

Should the data in line edit work with a compound primary key?
I cannot get the add new to create a row and wonder if this is the reason.

Works with Northwind OrderDetails where the key is complex (OrderID and ProductID):

I just tried a new blank app and the add button does not create a row. VS debug and logs show no issues. I am using WebAssembly .NET5 on a PostgreSQL database with a partitioned table. Here is the create table:

CREATE TABLE strax.st_rx_notification_types (
	tenant_id int8 NOT NULL,
	notification_type varchar(500)  null,
	spare1 text null,
	spare2 text null,
	spare3 text null,
	CONSTRAINT st_rx_notification_types_pkey PRIMARY KEY (tenant_id,uid)
PARTITION BY LIST (tenant_id);
CREATE TABLE strax.st_rx_notification_types_1 PARTITION OF strax.st_rx_notification_types FOR VALUES IN ('1');
CREATE TABLE strax.st_rx_notification_types_2 PARTITION OF strax.st_rx_notification_types FOR VALUES IN ('2');
CREATE TABLE strax.st_rx_notification_types_3 PARTITION OF strax.st_rx_notification_types FOR VALUES IN ('3');

Can you see if this works for you please?
P.S. I tried creating a page for the base table and another page for a partition table direct. Both have the same issue. The add button and code is created but does not create a row at runtime.

P.P.S. The table is empty to start with.

Can you debug the code? Do you get error? Will the code run?

The code runs, no errors. Step into just glides over with no errors raised.
I just added a row to the table in SQL and now the add button works. My gut feel is that the insertrow fails when the results IEnumerable is empty.
Maybe not fail but is adding to null???

@enchev, I have circled back to this issue with adding the first row in a multitenant partitioned table.
The database is postgres with tables partitioned by tenant_id.
The datagrid query has a predicate to limit the view based on the Security.User.TenantId.
The inline edit add does not work if there are no rows in the current partition.
If the tenant_id predicate is removed then the add button seems to work fine because there are other rows in other partitions.
If I add a dummy row to the partition using sql then there is no issue to add subsequent rows in the app. The issue is only when there are no rows in the partition.

In debug I see the last thing that happens is that tenant_id gets set before the program continues. If there is an existing row then the debug looks the same.

Here are the designer.cs code snippets:

        protected async System.Threading.Tasks.Task Load()
            ststudentschedule = new STracker.Models.Schools01Db.StStudentSchedule(){tenant_id=Security.User.TenantId.GetValueOrDefault()};

            if (string.IsNullOrEmpty(search)) {
                search = "";

            SelectedList = new List<STracker.Models.Schools01Db.StStudentSchedule>();

        protected async System.Threading.Tasks.Task Button0Click(MouseEventArgs args)
            await this.grid0.InsertRow(new STracker.Models.Schools01Db.StStudentSchedule{tenant_id=Security.User.TenantId.GetValueOrDefault()});
        protected async System.Threading.Tasks.Task Grid0LoadData(LoadDataArgs args)
                var schools01DbGetStStudentSchedulesResult = await Schools01Db.GetStStudentSchedules(filter:$@"(contains(student_id,""{search}"")) and {(string.IsNullOrEmpty(args.Filter)? "true" : args.Filter)} and (tenant_id eq 0 or tenant_id eq 1)", orderby:$@"{args.OrderBy}", top:args.Top, skip:args.Skip, count:args.Top != null && args.Skip != null);
                getStStudentSchedulesResult = schools01DbGetStStudentSchedulesResult.Value.AsODataEnumerable();

                getStStudentSchedulesCount = schools01DbGetStStudentSchedulesResult.Count;
            catch (System.Exception schools01DbGetStStudentSchedulesException)
                NotificationService.Notify(new NotificationMessage(){ Severity = NotificationSeverity.Error,Summary = $"Error",Detail = $"Unable to load StStudentSchedules" });

        protected async System.Threading.Tasks.Task Grid0RowCreate(dynamic args)
            args.tenant_id = Security.User.TenantId;

            var schools01DbCreateStStudentScheduleResult = await Schools01Db.CreateStStudentSchedule(stStudentSchedule:args);
            await grid0.Reload();

            await InvokeAsync(() => { StateHasChanged(); });

Hi @simon,

Check this thread for reference:

1 Like