public async Task UninstallAsync(IServiceProvider serviceProvider, Func <Task> unsinstallFunc)
        {
            //TODO:可以在基础模块里给出选项是否删除

            WeixinSenparcEntities mySenparcEntities = serviceProvider.GetService <WeixinSenparcEntities>();

            //指定需要删除的数据实体

            //注意:这里作为演示,删除了所有的表,实际操作过程中,请谨慎操作,并且按照删除顺序对实体进行排序!
            var dropTableKeys = EntitySetKeys.GetEntitySetInfo(this.XncfDatabaseDbContextType).Keys.ToList();

            //按照删除顺序排序
            var types = new[] { typeof(UserTag_WeixinUser), typeof(UserTag), typeof(WeixinUser), typeof(MpAccount) };

            types.ToList().AddRange(dropTableKeys);
            types = types.Distinct().ToArray();
            await base.DropTablesAsync(serviceProvider, mySenparcEntities, types);

            await base.UninstallAsync(serviceProvider, unsinstallFunc).ConfigureAwait(false);
        }
Example #2
0
        public override async Task UninstallAsync(IServiceProvider serviceProvider, Func <Task> unsinstallFunc)
        {
            //TODO:可以在基础模块里给出选项是否删除

            #region  除数据库(演示)

            var mySenparcEntitiesType = this.TryGetXncfDatabaseDbContextType;
            WeixinSenparcEntities mySenparcEntities = serviceProvider.GetService(mySenparcEntitiesType) as WeixinSenparcEntities;

            //指定需要删除的数据实体

            //注意:这里作为演示,在卸载模块的时候删除了所有本模块创建的表,实际操作过程中,请谨慎操作,并且按照删除顺序对实体进行排序!
            var dropTableKeys = EntitySetKeys.GetEntitySetInfo(this.TryGetXncfDatabaseDbContextType).Keys.ToArray();
            //按照删除顺序排序
            var types = new[] { typeof(UserTag_WeixinUser), typeof(UserTag), typeof(WeixinUser), typeof(MpAccount) };
            types.ToList().AddRange(dropTableKeys);
            types = types.Distinct().ToArray();
            //指定需要删除的数据实体
            await base.DropTablesAsync(serviceProvider, mySenparcEntities, types);

            #endregion

            await base.UninstallAsync(serviceProvider, unsinstallFunc).ConfigureAwait(false);
        }