예제 #1
0
        public static IQueryable <T> StageOnSQLite <T>(this IEnumerable <T> items, ChoETLSqliteSettings sqliteSettings = null)
            where T : class
        {
            Dictionary <string, PropertyInfo> PIDict = null;

            if (!typeof(T).IsDynamicType() && typeof(T) != typeof(object))
            {
                PIDict = ChoType.GetProperties(typeof(T)).ToDictionary(p => p.Name);
            }

            sqliteSettings = ValidateSettings <T>(sqliteSettings);
            LoadDataToDb(items, sqliteSettings, PIDict);

            if (!typeof(T).IsDynamicType() && typeof(T) != typeof(object))
            {
                var ctx = new ChoETLSQLiteDbContext <T>(sqliteSettings.GetConnectionString());
                ctx.Log = sqliteSettings.Log;
                var dbSet = ctx.Set <T>();
                return(dbSet);
            }
            else
            {
                return(Enumerable.Empty <T>().AsQueryable());
            }
        }
예제 #2
0
        public static IQueryable <T> StageOnSQLite <T>(this IEnumerable <T> items, ChoETLSqliteSettings sqliteSettings = null)
            where T : class
        {
            if (typeof(T) == typeof(ExpandoObject) || typeof(T) == typeof(object))
            {
                throw new NotSupportedException();
            }

            Dictionary <string, PropertyInfo> PIDict = ChoType.GetProperties(typeof(T)).ToDictionary(p => p.Name);

            sqliteSettings = ValidateSettings <T>(sqliteSettings);
            LoadDataToDb(items, sqliteSettings, PIDict);

            var ctx   = new ChoETLSQLiteDbContext <T>(sqliteSettings.DatabaseFilePath);
            var dbSet = ctx.Set <T>();

            return(dbSet);
        }