Esempio n. 1
0
        /// <summary>
        /// Save relations.
        /// </summary>
        /// <param name="dataProvider">Implementation of the data provider used to access data.</param>
        /// <param name="isInserting">Indication of whether we are inserting or updating</param>
        public virtual void SaveRelations(IDataProviderBase <MySqlDataReader, MySqlCommand> dataProvider, bool isInserting)
        {
            ArgumentNullGuard.NotNull(dataProvider, nameof(dataProvider));

            if (Identifier.HasValue == false)
            {
                throw new IntranetRepositoryException(Resource.GetExceptionMessage(ExceptionMessage.IllegalValue, Identifier, "Identifier"));
            }

            DataProxyCache.AddDataProxyCollectionToCache(CacheName, this, translationProxy => translationProxy.Identifier == Identifier.Value);
        }
Esempio n. 2
0
        /// <summary>
        /// Delete relations.
        /// </summary>
        /// <param name="dataProvider">Implementation of the data provider used to access data.</param>
        public virtual void DeleteRelations(IDataProviderBase <MySqlDataReader, MySqlCommand> dataProvider)
        {
            ArgumentNullGuard.NotNull(dataProvider, nameof(dataProvider));

            if (Identifier.HasValue == false)
            {
                throw new IntranetRepositoryException(Resource.GetExceptionMessage(ExceptionMessage.IllegalValue, Identifier, "Identifier"));
            }

            DataProxyCache.RemoveDataProxyCollectionToCache(CacheName, this, foreignKeyProxy => foreignKeyProxy.Identifier == Identifier.Value);
        }
Esempio n. 3
0
        /// <summary>
        /// Gets foreign keys for a domain object in the food waste domain.
        /// </summary>
        /// <param name="dataProvider">Implementation of the data provider used to access data.</param>
        /// <param name="foreignKeyForIdentifier">Identifier for the given domain object on which to get the foreign keys.</param>
        /// <returns>Foreign keys for a domain object in the food waste domain.</returns>
        internal static IEnumerable <ForeignKeyProxy> GetDomainObjectForeignKeys(IDataProviderBase <MySqlDataReader, MySqlCommand> dataProvider, Guid foreignKeyForIdentifier)
        {
            ArgumentNullGuard.NotNull(dataProvider, nameof(dataProvider));

            HashSet <ForeignKeyProxy> cache = DataProxyCache.GetCachedDataProxyCollection <ForeignKeyProxy>(CacheName);

            if (cache.Any(foreignKeyProxy => foreignKeyProxy.ForeignKeyForIdentifier == foreignKeyForIdentifier))
            {
                return(cache.Where(foreignKeyProxy => foreignKeyProxy.ForeignKeyForIdentifier == foreignKeyForIdentifier).ToList());
            }

            using (IFoodWasteDataProvider subDataProvider = (IFoodWasteDataProvider)dataProvider.Clone())
            {
                List <ForeignKeyProxy> result = new List <ForeignKeyProxy>(subDataProvider.GetCollection <ForeignKeyProxy>(BuildSystemDataCommandForSelecting("WHERE fk.ForeignKeyForIdentifier=@foreignKeyForIdentifier", systemDataCommandBuilder => systemDataCommandBuilder.AddForeignKeyForIdentifierParameter(foreignKeyForIdentifier))));
                DataProxyCache.AddDataProxyCollectionToCache(CacheName, result, foreignKeyProxy => foreignKeyProxy.ForeignKeyForIdentifier == foreignKeyForIdentifier);
                return(result);
            }
        }
Esempio n. 4
0
        /// <summary>
        /// Gets the translations for a given translatable domain object in the food waste domain.
        /// </summary>
        /// <param name="dataProvider">Implementation of the data provider used to access data.</param>
        /// <param name="translationOfIdentifier">Identifier for the given domain object on which to get the translations.</param>
        /// <returns>Translations for a given translatable domain object in the food waste domain.</returns>
        internal static IEnumerable <TranslationProxy> GetDomainObjectTranslations(IDataProviderBase <MySqlDataReader, MySqlCommand> dataProvider, Guid translationOfIdentifier)
        {
            ArgumentNullGuard.NotNull(dataProvider, nameof(dataProvider));

            HashSet <TranslationProxy> cache = DataProxyCache.GetCachedDataProxyCollection <TranslationProxy>(CacheName);

            if (cache.Any(translationProxy => translationProxy.TranslationOfIdentifier == translationOfIdentifier))
            {
                return(cache.Where(translationProxy => translationProxy.TranslationOfIdentifier == translationOfIdentifier).ToList());
            }

            using (IFoodWasteDataProvider subDataProvider = (IFoodWasteDataProvider)dataProvider.Clone())
            {
                List <TranslationProxy> result = new List <TranslationProxy>(subDataProvider.GetCollection <TranslationProxy>(BuildSystemDataCommandForSelecting("WHERE t.OfIdentifier=@ofIdentifier ORDER BY ti.CultureName", systemDataCommandBuilder => systemDataCommandBuilder.AddTranslationOfIdentifierParameter(translationOfIdentifier))));
                DataProxyCache.AddDataProxyCollectionToCache(CacheName, result, translationProxy => translationProxy.TranslationOfIdentifier == translationOfIdentifier);
                return(result);
            }
        }