private PancakeContext _db; //todo: подключение должно быть одно на все сервисы? public void Init(PancakeConfiguration configuration) { try { _db = new PancakeContext(configuration); IsInitialized = true; } catch (Exception e) { Console.WriteLine($"Error connecting to database: {e}"); throw; } }
public void Init(PancakeConfiguration configuration) { if (!IsInitialized) { try { _db = new PancakeContext(configuration); IsInitialized = true; } catch (Exception e) { Console.WriteLine($"Error connecting to database: {e}"); throw; } } else { Console.WriteLine($"RandomWordsService already initialized!"); } }