Hello to all,
i have a question about definig a 1:0 relationshipt in MS SqlServer.
i have a model like this:
CREATE TABLE [dbo].[A1]
(
[A1Id] INT NOT NULL PRIMARY KEY IDENTITY,
[Text] NVARCHAR(50) NOT NULL
)
CREATE TABLE [dbo].[B1]
(
[A1Id] INT NOT NULL PRIMARY KEY,
[Text] NVARCHAR(50) NULL,
CONSTRAINT [FK_B1_A1] FOREIGN KEY (A1Id) REFERENCES [A1].[A1Id]
)
CREATE TABLE [dbo].[B2]
(
[A1Id] INT NOT NULL PRIMARY KEY,
[Text] NVARCHAR(50) NULL,
CONSTRAINT [FK_B2_A1] FOREIGN KEY ([A1Id]) REFERENCES [A1].[A1Id]
)
CREATE TABLE [dbo].[C1]
(
[C1Id] INT NOT NULL PRIMARY KEY IDENTITY,
[B1Id] INT NOT NULL,
[B2Id] INT NOT NULL,
CONSTRAINT [FK_C1_B1] FOREIGN KEY ([B1Id]) REFERENCES [B1].[A1Id],
CONSTRAINT [FK_C1_B2] FOREIGN KEY ([B2Id]) REFERENCES [B2].[A1Id]
)
This should be the correct definition for sub classes or table splitting. A1 can have ONE B1 AND A1 can have ONE B2. B1 and B2 have ONE C1(Dropdown). C1 can Have MANY B1 and MANY B2
In Radzen when i create crud pages für A1 including B1 and B2 only A1 property is displayed on Add and Edit page. Im missing the B1 and B2 properties and therefore the C1 Dropdown for B1 and B2.
CREATE TABLE [dbo].[A1]
(
[A1Id] INT NOT NULL PRIMARY KEY IDENTITY,
[Text] NVARCHAR(50) NOT NULL,
[B1Id] INT NULL UNIQUE,
[B2Id] INT NULL UNIQUE,
CONSTRAINT [FK_A1_B1] FOREIGN KEY ([B1Id]) REFERENCES [B1][B1Id],
CONSTRAINT [FK_A1_B2] FOREIGN KEY ([B2Id]) REFERENCES [B2][B2Id]
)
CREATE TABLE [dbo].[B1]
(
[B1Id] INT NOT NULL PRIMARY KEY UNIQUE IDENTITY,
[Text] NVARCHAR(50) NULL,
[C1Id] INT NOT NULL,
CONSTRAINT [FK_B1_C1] FOREIGN KEY ([C1Id]) REFERENCES [C1][C1Id]
)
CREATE TABLE [dbo].[B2]
(
[B2Id] INT NOT NULL Primary Key Unique IDENTITY,
[Text] NVARCHAR(50) NULL,
[C1Id] INT NOT NULL,
CONSTRAINT [FK_B2_C1] FOREIGN KEY ([C1Id]) REFERENCES [C1][C1Id]
)
CREATE TABLE [dbo].[C1]
(
[C1Id] INT NOT NULL PRIMARY KEY IDENTITY,
[Text] NVARCHAR(50) NOT NULL
)
This is the Add Page for A1:
But in Table Splitting i want to insert B1.Text and/or B2.TEXT on the same form as A1.
A form with A1.Text, B1.Text and B2.Text and on clicking save all 3 Tabledata is associated and inserted.
Something like this:
context.A1.Add(B1);
context.A1.Add(B2);
context.Add(A1);
context.SaveChanges();
The autogenerated forms will not do that. You can however add more form fields and bind them to the related entity. You will have to fetch it from the DB - check how the generated code retrieves it in the Load event of the page.