Example #1
0
        /// <summary>
        ///     The add datatable properties.
        /// </summary>
        /// <param name="session">
        ///     The session.
        /// </param>
        /// <param name="datatableId">
        ///     The datatable id.
        /// </param>
        /// <param name="properties">
        ///     The properties.
        /// </param>
        /// <typeparam name="TEntity">
        ///     The type of entity
        /// </typeparam>
        public static void AddDatatableProperties <TEntity>(
            this HttpSessionStateBase session, string datatableId, DatatableSessionObject <TEntity> properties)
            where TEntity : class
        {
            IDictionary <string, DatatableSessionObject <TEntity> > dictionary =
                session.GetOrMakeDatatablesDictionary <TEntity>();

            dictionary[datatableId] = properties;
            session[Key]            = dictionary;
        }
Example #2
0
        /// <summary>
        ///     The get datatable properties.
        /// </summary>
        /// <param name="session">
        ///     The session.
        /// </param>
        /// <param name="datatableId">
        ///     The datatable id.
        /// </param>
        /// <typeparam name="TEntity">
        ///     The type of entity
        /// </typeparam>
        /// <returns>
        ///     The <see cref="DatatableSessionObject" />.
        /// </returns>
        /// <exception cref="ArgumentException">
        ///     If there is no datatables dictionary in the session
        /// </exception>
        public static DatatableSessionObject <TEntity> GetDatatableProperties <TEntity>(
            this HttpSessionStateBase session, string datatableId) where TEntity : class
        {
            IDictionary <string, DatatableSessionObject <TEntity> > dictionary =
                session.GetOrMakeDatatablesDictionary <TEntity>();

            if (dictionary.ContainsKey(datatableId))
            {
                return(dictionary[datatableId]);
            }
            throw new ArgumentException("No datatable properties found in session!", "datatableId");
        }