Beispiel #1
0
 /// <summary>
 /// Ensures schemas of an entity in SQL database
 /// </summary>
 /// <param name="definition"></param>
 /// <param name="dataSource"></param>
 /// <param name="tracker"></param>
 /// <param name="cancellationToken"></param>
 /// <returns></returns>
 public static async Task EnsureSqlSchemasAsync(EntityDefinition definition, DataSource dataSource, Action <string, Exception> tracker = null, CancellationToken cancellationToken = default)
 {
     if (definition != null && dataSource != null && dataSource.Mode.Equals(RepositoryMode.SQL))
     {
         try
         {
             tracker?.Invoke($"Ensure schemas of SQL: {definition.Type} [{dataSource.Name} @ {dataSource.Mode} => {definition.TableName}]", null);
             if (tracker == null && RepositoryMediator.IsDebugEnabled)
             {
                 RepositoryMediator.WriteLogs($"Ensure schemas of SQL: {definition.Type} [{dataSource.Name} @ {dataSource.Mode} => {definition.TableName}]", null);
             }
             await definition.EnsureSchemasAsync(dataSource, tracker, cancellationToken).ConfigureAwait(false);
         }
         catch (Exception ex)
         {
             tracker?.Invoke($"Error occurred while ensuring schemas of SQL: {definition.Type} [{dataSource.Name} @ {dataSource.Mode} => {definition.TableName}]", ex);
             if (tracker == null)
             {
                 RepositoryMediator.WriteLogs($"Error occurred while ensuring schemas of SQL: {definition.Type} [{dataSource.Name} @ {dataSource.Mode} => {definition.TableName}]", ex);
             }
         }
     }
 }