Esempio n. 1
0
        public override async Task Run()
        {
            DBComponent dbComponent = Game.Scene.GetComponent <DBComponent>();

            try
            {
                // 执行查询数据库任务
                FilterDefinition <Component> filterDefinition = new JsonFilterDefinition <Component>(this.Json);
                IAsyncCursor <Component>     cursor           = await dbComponent.Get2Collection(this.CollectionName).FindAsync(filterDefinition);

                List <Component> components = await cursor.ToListAsync();

                this.Tcs.SetResult(components);
            }
            catch (Exception e)
            {
                this.Tcs.SetException(new Exception($"查询数据库异常! {CollectionName} {this.Json}", e));
            }
        }