Exemple #1
0
        /// <summary>
        /// Executes a Select statement defined by the expression on a database and returns the results
        /// </summary>
        /// <typeparam name="T">The Type of the table, must have Table Attribute</typeparam>
        /// <param name="expression">A Linq Expression on a certain Table</param>
        /// <returns>A List of objects of Type T </returns>
        public IEnumerable <T> GetEnumerable <T>(Expression expression)
        {
            if (IsTypeATable(typeof(T)))
            {
                IEnumerable <T> list       = _db.Select <T>(expression);
                var             enumerable = list.ToList();
                foreach (var obj in enumerable)
                {
                    _ct.Track(obj);
                }

                return(enumerable);
            }
            else
            {
                throw new InvalidOperationException(
                          $"{typeof(T)} is not a valid Table Type, please set correct Attributes");
            }
        }