Low performance on editor.PreCreate server-sive event

Low performance on editor.PreCreate server-sive event

fabiomoggifabiomoggi Posts: 9Questions: 4Answers: 0

Hi Allan,

As part of my web site's business logic, I need to dynamically determine a value to a field called billingId before adding the transaction object to the database. I am taking advantage of the PreCreate event on my .NET Web API Controller as following:

editor.PreCreate += (sender, e) => {
                    Dictionary<string, object> bankTransaction = (Dictionary<string, object>) e.Values["BankTransaction"];

                    var billing = 3; //ToDo: develop custom function to get billingId from DB

                    if (bankTransaction.ContainsKey("billingId") == false)
                        bankTransaction.Add("billingId", billing);
                };

After incluing the code above, the web site seems to have taken a major hit on performance. It is taking 5 secs to update the database. When removing the precreate event, it takes miliseconds.

Are there alternatives or best practice to the code I wrote?

Thanks

This discussion has been closed.