예제 #1
0
        /// <summary>
        /// Get tracked entities
        /// </summary>
        /// <typeparam name="T"></typeparam>
        /// <returns></returns>
        public static IEnumerable <Type> GetTrackedEntities <T>(this T context) where T : DbContext
        {
            var result = new List <Type>();
            var dbSets = context.GetType().GetProperties();

            foreach (var dbSet in dbSets)
            {
                var genericType = dbSet.PropertyType.GenericTypeArguments.FirstOrDefault();
                if (genericType == null)
                {
                    continue;
                }
                var match = TrackerFactory.IsTrackable(genericType).Item1;
                if (match)
                {
                    result.Add(genericType);
                }
            }

            return(result);
        }