CRUD Pages generation with referenced table

Hi!

I am a little trying the radzen trial trying some small things to find out if i can use this in future projects.

If i try to create a CRUD Page with new and edit by using a table that uses a reference to another table the combobox in new and edit seems to be broken. It seems to work on a datagrid with the same datasource.

Here ist the MS-SQL for the 2 Tables:
USE [CManagement]
GO

/****** Object:  Table [dbo].[alg_kunden]    Script Date: 01.10.2019 15:06:30 ******/
SET ANSI_NULLS ON
GO

SET QUOTED_IDENTIFIER ON
GO

CREATE TABLE [dbo].[alg_kunden](
	[GUID_Kunde] [uniqueidentifier] ROWGUIDCOL  NOT NULL,
	[Kundenname] [nvarchar](max) NOT NULL,
 CONSTRAINT [PK_alg_kunden] PRIMARY KEY CLUSTERED 
(
	[GUID_Kunde] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON, OPTIMIZE_FOR_SEQUENTIAL_KEY = OFF) ON [PRIMARY]
) ON [PRIMARY] TEXTIMAGE_ON [PRIMARY]
GO

ALTER TABLE [dbo].[alg_kunden] ADD  CONSTRAINT [DF_alg_kunden_GUID_Kunde]  DEFAULT (newid()) FOR [GUID_Kunde]
GO

USE [CManagement]
GO

/****** Object:  Table [dbo].[zem_stundenliste]    Script Date: 01.10.2019 15:06:55 ******/
SET ANSI_NULLS ON
GO

SET QUOTED_IDENTIFIER ON
GO

CREATE TABLE [dbo].[zem_stundenliste](
	[GUID_Zeiterfassung] [uniqueidentifier] ROWGUIDCOL  NOT NULL,
	[Kunde] [uniqueidentifier] NOT NULL,
	[Tag] [date] NULL,
	[Stundenanzahl] [float] NULL,
	[Beschreibung] [text] NULL,
 CONSTRAINT [PK_zem_stundenliste] PRIMARY KEY CLUSTERED 
(
	[GUID_Zeiterfassung] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON, OPTIMIZE_FOR_SEQUENTIAL_KEY = OFF) ON [PRIMARY]
) ON [PRIMARY] TEXTIMAGE_ON [PRIMARY]
GO

ALTER TABLE [dbo].[zem_stundenliste] ADD  CONSTRAINT [DF_zem_stundenliste_GUID_Zeiterfassung]  DEFAULT (newid()) FOR [GUID_Zeiterfassung]
GO

ALTER TABLE [dbo].[zem_stundenliste]  WITH CHECK ADD  CONSTRAINT [FK_t.ZEM.Stundenliste_t.ALG.Kunden] FOREIGN KEY([Kunde])
REFERENCES [dbo].[alg_kunden] ([GUID_Kunde])
GO

ALTER TABLE [dbo].[zem_stundenliste] CHECK CONSTRAINT [FK_t.ZEM.Stundenliste_t.ALG.Kunden]
GO

I generated CRUD sages by using "ZemStundenliste" and did no change to any page.

On the Edit i get this:

If i start the application and try to add a new record - and get an error in the console output:

dotnet: info: Microsoft.EntityFrameworkCore.Database.Command[20100]
      Executing DbCommand [Parameters=[], CommandType='Text', CommandTimeout='30']
      SELECT [z].[GUID_Zeiterfassung], [z].[Beschreibung], [z].[Kunde], [z].[Stundenanzahl], [z].[Tag], [a].[GUID_Kunde], [a].[Kundenname]
      FROM [dbo].[zem_stundenliste] AS [z]
      INNER JOIN [dbo].[alg_kunden] AS [a] ON [z].[Kunde] = [a].[GUID_Kunde]

dotnet: info: Microsoft.EntityFrameworkCore.Database.Command[20100]
      Executing DbCommand [Parameters=[], CommandType='Text', CommandTimeout='30']
      SELECT [a].[GUID_Kunde], [a].[Kundenname]
      FROM [dbo].[alg_kunden] AS [a]

dotnet: warn: Microsoft.AspNetCore.Components.Server.Circuits.RemoteRenderer[100]
      Unhandled exception rendering component: Object reference not set to an instance of an object.
System.NullReferenceException: Object reference not set to an instance of an object.
   at Radzen.PropertyAccess.GetValue(Object value, String path)
   at Radzen.PropertyAccess.GetItemOrValueFromProperty(Object item, String property)
   at Radzen.Blazor.RadzenDropDown.BuildRenderTree(RenderTreeBuilder __builder)
   at Microsoft.AspNetCore.Components.ComponentBase.<.ctor>b__6_0(RenderTreeBuilder builder)
   at Microsoft.AspNetCore.Components.Rendering.ComponentState.RenderIntoBatch(RenderBatchBuilder batchBuilder, RenderFragment renderFragment)
   at Microsoft.AspNetCore.Components.RenderTree.Renderer.RenderInExistingBatch(RenderQueueEntry renderQueueEntry)
   at Microsoft.AspNetCore.Components.RenderTree.Renderer.ProcessRenderQueue()

dotnet: fail: Microsoft.AspNetCore.Components.Server.Circuits.CircuitHost[111]
      Unhandled exception in circuit 'fbY_Qv3H0H4T9mRT-C8i9V8MDDVg3OfCy-8VqKsNg34'.
System.NullReferenceException: Object reference not set to an instance of an object.
   at Radzen.PropertyAccess.GetValue(Object value, String path)
   at Radzen.PropertyAccess.GetItemOrValueFromProperty(Object item, String property)
   at Radzen.Blazor.RadzenDropDown.BuildRenderTree(RenderTreeBuilder __builder)
   at Microsoft.AspNetCore.Components.ComponentBase.<.ctor>b__6_0(RenderTreeBuilder builder)
   at Microsoft.AspNetCore.Components.Rendering.ComponentState.RenderIntoBatch(RenderBatchBuilder batchBuilder, RenderFragment renderFragment)
   at Microsoft.AspNetCore.Components.RenderTree.Renderer.RenderInExistingBatch(RenderQueueEntry renderQueueEntry)
   at Microsoft.AspNetCore.Components.RenderTree.Renderer.ProcessRenderQueue()

dotnet: info: Microsoft.AspNetCore.Routing.EndpointMiddleware[1]
      Executed endpoint '/_blazor'

Am I doing something wrong? Thanks :slight_smile:

This exception is already fixed (raised when the property name is invalid). Can you send us your database schema at info@radzen.com to test your case locally to check if our fix is complete?

Got the Mail saying that it is fixed in the next release thanks,
Is there any way to get arround it till the release? I want to get some more details within my trial time to see if i can get handy with radzen :slight_smile:
Thanks

Hi @chackl,

We will do our best to publish release tomorrow!

Best Regards,
Vladimir

Hi @chackl,

Just released Radzen 2.25.6!

1 Like

Thanks for notify me :slight_smile:

Well - Generation Progress seems to work now - but if i execute the server and try to add a record it shows me up this in the console:

dotnet: warn
dotnet: : Microsoft.AspNetCore.Components.Server.Circuits.RemoteRenderer[100]
      Unhandled exception rendering component: Unable to cast object of type 'System.Guid' to type 'System.String'.
System.InvalidCastException: Unable to cast object of type 'System.Guid' to type 'System.String'.
   at Radzen.ConvertType.ChangeType(Object value, Type type)
   at System.Dynamic.UpdateDelegates.UpdateAndExecute3[T0,T1,T2,TRet](CallSite site, T0 arg0, T1 arg1, T2 arg2)
   at Radzen.Blazor.RadzenTemplateForm`1.SetValue(Object component)
   at Radzen.Blazor.RadzenTemplateForm`1.OnSubmit(EditContext args)
   at Radzen.Blazor.RadzenTemplateForm`1.<BuildRenderTree>b__0_0(EditContext args)
--- End of stack trace from previous location where exception was thrown ---
   at Microsoft.AspNetCore.Components.ComponentBase.CallStateHasChangedOnAsyncCompletion(Task task)
   at Microsoft.AspNetCore.Components.Forms.EditForm.HandleSubmitAsync()
   at Microsoft.AspNetCore.Components.ComponentBase.CallStateHasChangedOnAsyncCompletion(Task task)
   at Microsoft.AspNetCore.Components.RenderTree.Renderer.GetErrorHandledTask(Task taskToHandle)

dotnet: fail: Microsoft.AspNetCore.Components.Server.Circuits.CircuitHost[111]
      Unhandled exception in circuit 'IhXGWM2uun0vAY5gNuEv_mtEZ6Ei0IFVpO9fbudI09Q'.
System.InvalidCastException: Unable to cast object of type 'System.Guid' to type 'System.String'.
   at Radzen.ConvertType.ChangeType(Object value, Type type)
   at System.Dynamic.UpdateDelegates.UpdateAndExecute3[T0,T1,T2,TRet](CallSite site, T0 arg0, T1 arg1, T2 arg2)
   at Radzen.Blazor.RadzenTemplateForm`1.SetValue(Object component)
   at Radzen.Blazor.RadzenTemplateForm`1.OnSubmit(EditContext args)
   at Radzen.Blazor.RadzenTemplateForm`1.<BuildRenderTree>b__0_0(EditContext args)
--- End of stack trace from previous location where exception was thrown ---
   at Microsoft.AspNetCore.Components.ComponentBase.CallStateHasChangedOnAsyncCompletion(Task task)
   at Microsoft.AspNetCore.Components.Forms.EditForm.HandleSubmitAsync()
   at Microsoft.AspNetCore.Components.ComponentBase.CallStateHasChangedOnAsyncCompletion(Task task)
   at Microsoft.AspNetCore.Components.RenderTree.Renderer.GetErrorHandledTask(Task taskToHandle)

Seems to be a Problem when converting the GUID eaven if i delete de GUID Text.
Example was on the same Database as i sent you via mail some days ago.

Any hints what i've done wrong?

This is definitely a bug - we will publish fix tomorrow.

1 Like

Radzen 1.0.10 just published to NuGet with fix for this exception- you can update the reference in your project.

1 Like