-
Hello all, Im have been trying to figure this out. I cant seem to call the database from the BusinessEdit object OnPropertyChange method and also from AddBusinessRules method. I keep getting the following error, "Synchronous data access is not supported on this runtime. Please use async data access methods" I tried several things but no luck. I tried to change the OnPropertyChange to async but I could not find any methods to convert them to async. This works fine from the razor pages since they are all async. So basically the question is how do I access the database from the server side/business objects. Im not sure if the ApplicationContext.GetRequiredService is the correct way to do it. I will keep doing some research. Thank you.
and
and
|
Beta Was this translation helpful? Give feedback.
Replies: 3 comments 2 replies
-
I didn't understand your 'use case' : ) but here is something I have done in the past (no DI back then) |
Beta Was this translation helpful? Give feedback.
-
The exception is telling you that your code is running in a .NET runtime environment where synchronous server calls aren't supported, so your data portal calls need to be async. It isn't about your calling code (what you are showing here), it is about the called code - specifically where you are actually using the data portal. Your |
Beta Was this translation helpful? Give feedback.
-
After doing some research I found the issue it was a combination of two things. First, I had to correct my code to the following which still needs some work:
Then I realized that when I debug on a break point my IDE would freeze. I thought the code wasn’t working. After I removed all the break points it ran without any issues. I got another problem but I will ask another question, so it has its own topic. |
Beta Was this translation helpful? Give feedback.
After doing some research I found the issue it was a combination of two things. First, I had to correct my code to the following which still needs some work: