예제 #1
0
        protected override void AddInConditionToCurrentGroup <TEntity, TMember>(
            Expression <Func <TEntity, TMember> > selector,
            TMember[] values,
            LogicalOperator locigalOperator,
            string alias,
            string tableName,
            string tableSchema)
        {
            if (values == null || !values.Any())
            {
                return;
            }
            var conditions           = currentGroup.Conditions;
            var whereClauseCondition = new WhereClauseCondition();

            whereClauseCondition.Alias           = alias;
            whereClauseCondition.LocigalOperator = locigalOperator;
            whereClauseCondition.LeftTable       =
                string.IsNullOrWhiteSpace(tableName) ? TableNameFromType <TEntity>() : tableName;
            whereClauseCondition.LeftSchema = string.IsNullOrWhiteSpace(tableSchema) ? "dbo" : tableSchema;
            whereClauseCondition.Left       = GetMemberColumnName(ConvertExpression(selector));
            whereClauseCondition.Operator   = "IN";
            whereClauseCondition.Right      = "(" + string.Join(", ", values.Select(v => FormatValue(v))) + ")";
            conditions.Add(whereClauseCondition);
            IsClean = false;
        }
예제 #2
0
        protected override void AddBetweenConditionToCurrentGroup <TEntity, TMember>(
            Expression <Func <TEntity, TMember> > selector,
            TMember start,
            TMember end,
            LogicalOperator locigalOperator,
            string alias,
            string tableName,
            string tableSchema)
        {
            var conditions1           = currentGroup.Conditions;
            var whereClauseCondition1 = new WhereClauseCondition();

            whereClauseCondition1.Alias           = alias;
            whereClauseCondition1.LocigalOperator = locigalOperator;
            whereClauseCondition1.LeftTable       =
                string.IsNullOrWhiteSpace(tableName) ? TableNameFromType <TEntity>() : tableName;
            whereClauseCondition1.LeftSchema = string.IsNullOrWhiteSpace(tableSchema) ? "dbo" : tableSchema;
            whereClauseCondition1.Left       = GetMemberColumnName(ConvertExpression(selector));
            whereClauseCondition1.Operator   = ">=";
            whereClauseCondition1.Right      = FormatValue(start);
            conditions1.Add(whereClauseCondition1);
            var conditions2           = currentGroup.Conditions;
            var whereClauseCondition2 = new WhereClauseCondition();

            whereClauseCondition2.Alias           = alias;
            whereClauseCondition2.LocigalOperator = LogicalOperator.And;
            whereClauseCondition2.LeftTable       =
                string.IsNullOrWhiteSpace(tableName) ? TableNameFromType <TEntity>() : tableName;
            whereClauseCondition2.LeftSchema = string.IsNullOrWhiteSpace(tableSchema) ? "dbo" : tableSchema;
            whereClauseCondition2.Left       = GetMemberColumnName(ConvertExpression(selector));
            whereClauseCondition2.Operator   = "<=";
            whereClauseCondition2.Right      = FormatValue(end);
            conditions2.Add(whereClauseCondition2);
            IsClean = false;
        }
예제 #3
0
        protected override IWhereClauseBuilder AddConditionToCurrentGroup <TEntity>(
            Expression <Func <TEntity, bool> > expression,
            LogicalOperator locigalOperator,
            string alias       = null,
            string tableName   = null,
            string tableSchema = null)
        {
            ThrowIfNotInitialised();
            IsClean = false;
            var conditions           = currentGroup.Conditions;
            var whereClauseCondition = new WhereClauseCondition
            {
                Alias           = alias,
                LocigalOperator = locigalOperator,
                LeftTable       = string.IsNullOrWhiteSpace(tableName) ? TableNameFromType <TEntity>() : tableName,
                LeftSchema      = string.IsNullOrWhiteSpace(tableSchema) ? "dbo" : tableSchema,
                Left            = "_LambdaTree_",
                Right           = AtkExpressionWriterSql <TEntity> .AtkWhereWriteToString(expression, AtkExpSqlType.AtkWhere, "[",
                                                                                          "]")
            };

            conditions.Add(whereClauseCondition);
            return(this);
        }