public static ETTask <T> FindOneByUniqueIndex <T>(this DBComponent db, string collectionName, string indexName, T entity) where T : ComponentWithId
        {
            ETTaskCompletionSource <T> tcs = new ETTaskCompletionSource <T>();
            var parameters = DBHelper.GetParameterList(typeof(T), indexName, entity);
            DBQueryWithUniqueIndexTask task = ComponentFactory.Create <DBQueryWithUniqueIndexTask, string, List <Tuple <PropertyInfo, object> >, ETTaskCompletionSource <T> >
                                                  (collectionName, parameters, tcs);

            db.tasks[(int)((ulong)task.Id % DBComponent.taskCount)].Add(task);
            return(tcs.Task);
        }
Пример #2
0
        public async ETTask <T> FindOneByUniqueIndex <T>(string indexName, T entity, string collectionName = default) where T : ComponentWithId
        {
            Type type = typeof(T);

            if (string.IsNullOrEmpty(collectionName))
            {
                collectionName = type.Name.ToLower();
            }
            ETTaskCompletionSource <ComponentWithId> tcs = new ETTaskCompletionSource <ComponentWithId>();
            var parameters = DBHelper.GetParameterList(type, indexName, entity);
            DBQueryWithUniqueIndexTask task = ComponentFactory.Create <DBQueryWithUniqueIndexTask, string, List <Tuple <PropertyInfo, object> >, ETTaskCompletionSource <ComponentWithId> >
                                                  (collectionName, parameters, tcs);

            this.tasks[(int)((ulong)task.Id % taskCount)].Add(task);
            return((T)await tcs.Task);
        }
Пример #3
0
 public override void Awake(DBQueryWithUniqueIndexTask self, string collectionName, List <Tuple <PropertyInfo, object> > parameters, ETTaskCompletionSource <ComponentWithId> tcs)
 {
     self.CollectionName = collectionName;
     self.Tcs            = tcs;
     self.parameters     = parameters;
 }