Esempio n. 1
0
        public bool NeedToCreateTrackingTable(DbBuilderOption builderOption)
        {
            if (builderOption.HasFlag(DbBuilderOption.CreateOrUseExistingSchema))
            {
                return(!SqliteManagementUtils.TableExists(connection, transaction, trackingName.QuotedString));
            }

            return(false);
        }
        /// <summary>
        /// For a foreign key, check if the Parent table exists
        /// </summary>
        private bool EnsureForeignKeysTableExist(DmRelation foreignKey)
        {
            var childTable  = foreignKey.ChildTable;
            var parentTable = foreignKey.ParentTable;

            // The foreignkey comes from the child table
            var ds = foreignKey.ChildTable.DmSet;

            if (ds == null)
            {
                return(false);
            }

            // Check if the parent table is part of the sync configuration
            var exist = ds.Tables.Any(t => ds.IsEqual(t.TableName, parentTable.TableName));

            if (!exist)
            {
                return(false);
            }

            bool alreadyOpened = connection.State == ConnectionState.Open;

            try
            {
                if (!alreadyOpened)
                {
                    connection.Open();
                }

                return(SqliteManagementUtils.TableExists(connection, transaction, parentTable.TableName));
            }
            catch (Exception ex)
            {
                Debug.WriteLine($"Error during EnsureForeignKeysTableExist : {ex}");
                throw;
            }
            finally
            {
                if (!alreadyOpened && connection.State != ConnectionState.Closed)
                {
                    connection.Close();
                }
            }
        }
 /// <summary>
 /// Check if we need to create the table in the current database
 /// </summary>
 public bool NeedToCreateTable() =>
 !SqliteManagementUtils.TableExists(connection, transaction, tableName);
Esempio n. 4
0
 public bool NeedToCreateTrackingTable()
 {
     return(!SqliteManagementUtils.TableExists(connection, transaction, trackingName.QuotedString));
 }