Beispiel #1
0
        /// <summary>
        /// Loads the specified id.
        /// </summary>
        /// <typeparam name="T">Type of result.</typeparam>
        /// <param name="loader">The loader.</param>
        /// <param name="id">The id.</param>
        /// <param name="throwOnNotFound">if set to <c>true</c> [throw on not found].</param>
        /// <returns>Object with specified key</returns>
        public static T Load <T>(this ILoaderWithInclude <T> loader, object id, bool throwOnNotFound)
        {
            T loaded = loader.Load <T>(string.Format(CultureInfo.InvariantCulture, "{0}", id));

            if (throwOnNotFound && loaded == null)
            {
                throw new NotFoundException(typeof(T), id, string.Empty);
            }
            return(loaded);
        }
Beispiel #2
0
 internal TemporalMultiLoaderWithInclude(TemporalSessionOperation temporal, ILoaderWithInclude <T> loader)
 {
     _temporal = temporal;
     _loader   = loader;
 }
Beispiel #3
0
        /// <summary>
        /// Loads the specified ids.
        /// </summary>
        /// <typeparam name="T">Type of result.</typeparam>
        /// <param name="loader">The loader.</param>
        /// <param name="ids">The ids.</param>
        /// <returns>Array of object for specified ids.</returns>
        public static T[] Load <T>(this ILoaderWithInclude <T> loader, IEnumerable <object> ids)
        {
            var idents = ids.Select(id => string.Format(CultureInfo.InvariantCulture, "{0}", id));

            return(loader.Load(idents));
        }
Beispiel #4
0
 /// <summary>
 /// Loads the specified id.
 /// </summary>
 /// <typeparam name="T">Type of result.</typeparam>
 /// <param name="loader">The loader.</param>
 /// <param name="id">The id.</param>
 /// <returns>
 /// Object with specified key or exception if not found.
 /// </returns>
 public static T Load <T>(this ILoaderWithInclude <T> loader, object id)
 {
     return(Load(loader, id, true));
 }
Beispiel #5
0
 /// <summary>
 /// Loads the specified ids.
 /// </summary>
 /// <typeparam name="T">Type of result.</typeparam>
 /// <param name="loader">The loader.</param>
 /// <param name="ids">The ids.</param>
 /// <returns>Array of object for specified ids.</returns>
 public static T[] Load <T>(this ILoaderWithInclude <T> loader, params object[] ids)
 {
     return(Load(loader, ids.AsEnumerable()));
 }