示例#1
0
        /// <summary>
        /// Translates a list of objects to a database parameter using an adhoc translation (not contained in a TranslationProfile)
        /// </summary>
        /// <typeparam name="KTranslationDataType">Type of object to translate</typeparam>
        /// <param name="translationExpression">Translation expression to use in the translation</param>
        /// <param name="source">The data to translate to a data table</param>
        /// <param name="dbParameterSettings">Additional settings for generating the database parameter</param>
        /// <returns>Translated database parameter</returns>
        public static DbParameter AdhocTranslateToDbParameter <KTranslationDataType>(TranslationExpression <KTranslationDataType> translationExpression,
                                                                                     IEnumerable <KTranslationDataType> source, DbParameterSettings dbParameterSettings)
            where KTranslationDataType : new()
        {
            var tmpEngine             = new DbParameterTranslationEngine();
            var initialzedTranslation =
                InitializedTranslation.CreateInstance(translationExpression.Translation, new List <TranslationEngine> {
                tmpEngine
            });

            return(tmpEngine.WrapinDbParameter(tmpEngine.FillDataTable(initialzedTranslation, source), dbParameterSettings));
        }
示例#2
0
        /// <summary>
        /// Translates a list of objects to data table using an adhoc translation (not contained in a TranslationProfile)
        /// </summary>
        /// <typeparam name="KTranslationDataType">Type of object to translate</typeparam>
        /// <param name="translationExpression">Translation expression to use in the translation</param>
        /// <param name="source">The data to translate to a data table</param>
        /// <returns>Translated data table</returns>
        public static DataTable AdhocTranslate <KTranslationDataType>(TranslationExpression <KTranslationDataType> translationExpression,
                                                                      IEnumerable <KTranslationDataType> source)
            where KTranslationDataType : new()
        {
            var tmpEngine             = new SimpleTranslationEngine();
            var initialzedTranslation =
                InitializedTranslation.CreateInstance(translationExpression.Translation, new List <TranslationEngine> {
                tmpEngine
            });

            return(tmpEngine.FillDataTable(initialzedTranslation, source));
        }