Blazor server side empty objects in dataportal #2216
Answered
by
rockfordlhotka
Mikael-Pothier
asked this question in
Questions
-
Hello, I am new to Blazor and I am trying to insert an object using the dataportal. I create the object using this code var newCourtier = Courtier.NewCourtier();
newCourtier.NoCourtier = courtierToAdd.NoCourtier;
newCourtier.Adresse1 = courtierToAdd.Adresse1;
newCourtier.Province = courtierToAdd.Province;
newCourtier.CodePostal = courtierToAdd.CodePostal;
newCourtier.Email = courtierToAdd.Email;
return Task.Run(() => newCourtier.SaveAsync()).Result; When it goes in SaveAsync, it seems to create a new object because when it goes into DataPortal_Insert() my object is empty. Thank you for your help. |
Beta Was this translation helpful? Give feedback.
Answered by
rockfordlhotka
Apr 19, 2021
Replies: 1 comment 7 replies
-
I'd expect the code to be more like this: var newCourtier = await Courtier.NewCourtierAsync();
newCourtier.NoCourtier = courtierToAdd.NoCourtier;
newCourtier.Adresse1 = courtierToAdd.Adresse1;
newCourtier.Province = courtierToAdd.Province;
newCourtier.CodePostal = courtierToAdd.CodePostal;
newCourtier.Email = courtierToAdd.Email;
return await newCourtier.SaveAsync(); Client-side Blazor is single threaded (like browsers, JavaScript, and WebAssembly), so I have no idea what happens if you try to do Task.Run stuff. |
Beta Was this translation helpful? Give feedback.
7 replies
Answer selected by
Mikael-Pothier
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
I'd expect the code to be more like this:
Client-side Blazor is single threaded (like browsers, JavaScript, and WebAssembly), so I have no idea what happens if you try to do Task.Run stuff.