Пример #1
0
        /// <summary>
        /// 根据json查询条件查询
        /// </summary>
        /// <param name="self"></param>
        /// <param name="json"></param>
        /// <typeparam name="T"></typeparam>
        /// <returns></returns>
        public static async ETTask <List <ComponentWithId> > Query <T>(this DBProxyComponent self, string json) where T : ComponentWithId
        {
            Session             session             = Game.Scene.GetComponent <NetInnerComponent>().Get(self.dbAddress);
            DBQueryJsonResponse dbQueryJsonResponse = (DBQueryJsonResponse)await session.Call(new DBQueryJsonRequest { CollectionName = typeof(T).Name, Json = json });

            return(dbQueryJsonResponse.Components);
        }
Пример #2
0
        /// <summary>
        /// 根据json查询条件查询
        /// </summary>
        /// <param name="self"></param>
        /// <param name="json"></param>
        /// <typeparam name="T"></typeparam>
        /// <returns></returns>
        public static async Task <List <T> > SortQuery <T>(this DBProxyComponent self, string typeName, string queryJson, string sortJson, int count) where T : ComponentWithId
        {
            Session             session             = Game.Scene.GetComponent <NetInnerComponent>().Get(self.dbAddress);
            DBQueryJsonResponse dbQueryJsonResponse = (DBQueryJsonResponse)await session.Call(new DBSortQueryJsonRequest { CollectionName = typeName, QueryJson = queryJson, SortJson = sortJson, Count = count });

            return(ConversionType <T>(dbQueryJsonResponse.Components));
        }
Пример #3
0
        public async Task <List <T> > QueryJson <T>(string json, bool needCache = true) where T : ComponentWithId
        {
            List <T>            list                = new List <T>();
            Session             session             = Game.Scene.GetComponent <NetInnerComponent>().Get(dbAddress);
            DBQueryJsonResponse dbQueryJsonResponse = (DBQueryJsonResponse)await session.Call(new DBQueryJsonRequest { CollectionName = typeof(T).Name, Json = json, NeedCache = needCache });

            foreach (ComponentWithId component in dbQueryJsonResponse.Components)
            {
                list.Add((T)component);
            }
            return(list);
        }