In() публичный Метод

public In ( string token ) : Sql
token string
Результат Sql
Пример #1
0
        public async Task<IEnumerable<dynamic>> GetAsync(string resource, int userId, object[] resourceIds)
        {
            if(string.IsNullOrWhiteSpace(this.Database))
            {
                return null;
            }

            if(!this.SkipValidation)
            {
                if(!this.Validated)
                {
                    await this.ValidateAsync(AccessTypeEnum.Read, this.LoginId, this.Database, false).ConfigureAwait(false);
                }
                if(!this.HasAccess)
                {
                    Log.Information("Access to entity \"FlagView\" was denied to the user with Login ID {LoginId}. Resource: {Resource}, ResourceIds {ResourceIds}.", this.LoginId, resource, resourceIds);
                    throw new UnauthorizedException("Access is denied.");
                }
            }

            var sql = new Sql("SELECT * FROM config.flag_view");
            sql.Where("resource=@0", resource);
            sql.And("user_id=@0", userId);
            sql.Append("AND");
            sql.In("resource_id IN (@0)", resourceIds);

            return await Factory.GetAsync<dynamic>(this.Database, sql).ConfigureAwait(false);
        }
Пример #2
0
        public async Task<IEnumerable<dynamic>> GetAsync(long[] kanbanIds, object[] resourceIds)
        {
            if (string.IsNullOrWhiteSpace(this.Database))
            {
                return null;
            }

            if (!this.SkipValidation)
            {
                if (!this.Validated)
                {
                    await this.ValidateAsync(AccessTypeEnum.Read, this.LoginId, this.Database, false).ConfigureAwait(false);
                }
                if (!this.HasAccess)
                {
                    Log.Information(
                        "Access to entity \"KanbanDetail\" was denied to the user with Login ID {LoginId}. KanbanId: {KanbanIds}, ResourceIds {ResourceIds}.",
                        this.LoginId, kanbanIds, resourceIds);
                    throw new UnauthorizedException("Access is denied.");
                }
            }


            if (kanbanIds == null ||
                resourceIds == null ||
                !kanbanIds.Any() ||
                !resourceIds.Any())
            {
                return new List<dynamic>();
            }


            var sql = new Sql("SELECT * FROM config.kanban_details WHERE");
            sql.In("kanban_id IN(@0)", kanbanIds);
            sql.Append("AND");
            sql.In("resource_id IN(@0)", resourceIds);

            return await Factory.GetAsync<dynamic>(this.Database, sql).ConfigureAwait(false);
        }
Пример #3
0
        public async Task<IEnumerable<dynamic>> GetAsync(object[] primaryKeys)
        {
            if (string.IsNullOrWhiteSpace(this.Database))
            {
                return null;
            }

            if (!this.SkipValidation)
            {
                if (!this.Validated)
                {
                    await this.ValidateAsync(AccessTypeEnum.Read, this.LoginId, this.Database, false).ConfigureAwait(false);
                }
                if (!this.HasAccess)
                {
                    Log.Information(
                        $"Access to entity \"{this.FullyQualifiedObjectName}\" was denied to the user with Login ID {this.LoginId}. Keys: {primaryKeys}.");
                    throw new UnauthorizedException("Access is denied.");
                }
            }

            var sql = new Sql("SELECT * FROM {this.FullyQualifiedObjectName}");
            sql.Where("deleted=@0", false);
            sql.Append("AND");
            sql.In("\"{this.PrimaryKey}\" IN (@0)", primaryKeys);


            return await Factory.GetAsync<dynamic>(this.Database, sql).ConfigureAwait(false);
        }