c# - How to implement a dbContext in multiple classes -


code I'm not sure that <> DbContext a way "" 2 DbContext objects are the classes I have a general Siarudi functions, and each insert / edit, I while connected using those changes - Log_History unit I instead of repeating the same code in multiple classes, I became a public static method for adding a new Log_History unit E.

My initial thought was that it might not be a good idea. Will there be a concurrency issue using the 2 DbContext object? I'm not sure if I understood correctly, but the question was answered that many references are fine. In my DbContext as an argument of CreateOrder () , AddHistoryNote () ; Can that be an acceptable approach?

  public class Log {public static void AddHistoryNote (Guid UserId, string type, string extension) (rsContext repo = using {new rsContext (for)) {Log_History trans = new Log_History { UserId = UserId, Description = Type, Extension = Extension, HistoryDate = DateTime.Now}; Repo.log_History.Add (trans); Repo.SaveChanges (); }}} Public class DoStuff {private void CreateOrder (BT.TransactionInfo TransDetails) using {(rsContext repo = new rsContext ()) {rsDataAccess.Order newOrder = new rsDataAccess.Order {sum = TransDetails.Amount, OrderDate = DateTime. Now, position = position. RIDER_PAID, RequestId = TransDetails.RequestId}; 'Theory Log in here. Add history note (transdition userID, "transaction type", "my history note"); Repo.Orders.Add (newOrder); Repo.SaveChanges (); }}}}  

The problem I'm here to make sure that you think But nothing is there.

Such are no concurrency issues with a static method call is not your Dibisitiaksteks own static (if it happens, it would be a problem) and you are ready for a new instance.

Not to say that I would recommend doing this, but this is an error.


Comments

Popular posts from this blog

sqlite3 - UPDATE a table from the SELECT of another one -

c# - Showing a SelectedItem's Property -

javascript - Render HTML after each iteration in loop -