예제 #1
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);
            }
        }
예제 #2
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);
            }
        }