• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

C# ISqlBuilder类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了C#中ISqlBuilder的典型用法代码示例。如果您正苦于以下问题:C# ISqlBuilder类的具体用法?C# ISqlBuilder怎么用?C# ISqlBuilder使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



ISqlBuilder类属于命名空间,在下文中一共展示了ISqlBuilder类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C#代码示例。

示例1: Render

        public void Render(ISqlBuilder builder, params Expression[] args)
        {
            if (args.Length != 2)
            {
                throw new NotSupportedException(string.Format(Res.ArgumentCountError, "Right()", "", " 2 "));
            }
            //Right(t0.descript,case when CHARINDEX('c',t0.descript) = 0 then 0 else
            //(LEN(t0.descript)- (CHARINDEX('c',t0.descript)+LEN('c'))+1) end)

            builder.Append("Right(");
            builder.Visit(args[0]);
            builder.Append(",IIF(InStr(");
            builder.Visit(args[0]);
            builder.Append(",");
            builder.Visit(args[1]);
            builder.Append(") = 0,0,(LEN(");
            builder.Visit(args[0]);
            builder.Append(") - (InStr(");
            builder.Visit(args[0]);
            builder.Append(",");
            builder.Visit(args[1]);
            builder.Append(")+LEN(");
            builder.Visit(args[1]);
            builder.Append("))+1)))");
        }
开发者ID:jaykizhou,项目名称:elinq,代码行数:25,代码来源:RightFunctionView.cs


示例2: Render

 public void Render(ISqlBuilder builder, params Expression[] args)
 {
     if (args == null)
         throw new NotSupportedException("args");
     //if (args.Length != 1)
     //    throw new NotSupportedException("'IsNullOrWhiteSpace' function takes  1 arguments");
     var isNot = args.Length == 2;
     if (isNot)
     {
         builder.Append("(");
         builder.Visit(args[0]);
         builder.Append(" IS NOT NULL OR ");
         builder.Visit(args[0]);
         builder.Append(" <> '' OR LTRIM(");
         builder.Visit(args[0]);
         builder.Append(") = '')");
     }
     else
     {
         builder.Append("(");
         builder.Visit(args[0]);
         builder.Append(" IS NULL OR ");
         builder.Visit(args[0]);
         builder.Append(" = '' OR LTRIM(");
         builder.Visit(args[0]);
         builder.Append(") = '')");
     }
 }
开发者ID:CMONO,项目名称:elinq,代码行数:28,代码来源:IsNullOrWhiteSpaceFunctionView.cs


示例3: Render

        public void Render(ISqlBuilder builder, params Expression[] args)
        {
            if (args.Length != 2 && args.Length != 3)
            {
                throw new ArgumentException(string.Format(Res.ArgumentCountError, "CASE", "", " 2 or 3 "));
            }

            var whens = (args[0] as ICollection<Expression>).ToArray();
            var thens = (args[1] as ICollection<Expression>).ToArray();
            var @else = args[2] as Expression;

            builder.Append("CASE");

            var lenght = whens.Length;
            for (int i = 0; i < lenght; i++)
            {
                builder.Append(" WHEN ");
                builder.Visit(whens[i]);
                builder.Append(" THEN ");
                builder.Visit(thens[i]);
            }

            if (@else != null)
            {
                builder.Append(" ELSE ");
                builder.Visit(@else);
            }

            builder.Append(" END");
        }
开发者ID:CMONO,项目名称:elinq,代码行数:30,代码来源:CaseFunctionView.cs


示例4: Render

        public void Render(ISqlBuilder builder, params Expression[] args)
        {
            var value = args[1];
            var constExp = args[2] as ConstantExpression;
            if (constExp != null)
            {
                value = FormatValue(value,
                    (bool)constExp.Value
                    , (bool)(args[3] as ConstantExpression).Value
                    , (bool)(args[4] as ConstantExpression).Value);
            }
            else
            {
                var nv = args[2] as NamedValueExpression;
                if (nv != null)
                {
                    constExp = nv.Value as ConstantExpression;
                    value = FormatValue(value,
                   (bool)constExp.Value
                   , (bool)((args[3] as NamedValueExpression).Value as  ConstantExpression).Value
                   , (bool)((args[4] as NamedValueExpression).Value as ConstantExpression).Value);
                }
            }

            builder.Append("(");
            builder.Visit(args[0]);
            builder.Append(" LIKE ");
            builder.Visit(value);
            builder.Append(")");
        }
开发者ID:netcasewqs,项目名称:elinq,代码行数:30,代码来源:LikeFunctionView.cs


示例5: Render

 public void Render(ISqlBuilder builder, params Expression[] args)
 {
     if (args.Length != 2 && args.Length != 3)
     {
         throw new NotSupportedException(string.Format(Res.ArgumentCountError, "PadRight", "", "2 or 3"));
     }
     builder.Append("CASE WHEN LEN(");
     builder.Visit(args[0]);
     builder.Append(") >= ");
     builder.Visit(args[1]);
     builder.Append(" THEN ");
     builder.Visit(args[0]);
     builder.Append(" ELSE (");
     builder.Visit(args[0]);
     builder.Append("+");
     if (args.Length == 2)
     {
         builder.Append("SPACE(");
         builder.Visit(args[1]);
         builder.Append(" - LEN(");
         builder.Visit(args[0]);
         builder.Append(")))");
     }
     else
     {
         builder.Append("REPLICATE(");
         builder.Visit(args[2]);
         builder.Append(",");
         builder.Visit(args[1]);
         builder.Append(" - LEN(");
         builder.Visit(args[0]);
         builder.Append(")))");
     }
     builder.Append(" END");
 }
开发者ID:CMONO,项目名称:elinq,代码行数:35,代码来源:PadRightFunctionView.cs


示例6: Render

 public void Render(ISqlBuilder visitor, params Expression[] args)
 {
     if (args == null || (args.Length != 2 && args.Length != 3))
     {
         throw new NotSupportedException(string.Format(Res.ArgumentCountError, "remove()", "", " 2 or 3 "));
     }
     visitor.Append("IIF((LEN(");
     visitor.Visit(args[0]);
     visitor.Append(") < ");
     visitor.Visit(args[1]);
     visitor.Append("),NULL,REPLACE(");
     visitor.Visit(args[0]);
     visitor.Append(",MID(");
     visitor.Visit(args[0]);
     visitor.Append(",");
     visitor.Visit(args[1]);
     if (args.Length == 2)
     {
         visitor.Append(",8000)");
     }
     else
     {
         visitor.Append(",");
         visitor.Visit(args[2]);
         visitor.Append(")");
     }
     visitor.Append(",''))");
 }
开发者ID:jaykizhou,项目名称:elinq,代码行数:28,代码来源:RemoveFunctionView.cs


示例7: Render

 public virtual void Render(ISqlBuilder builder, params Expression[] args)
 {
     builder.Append(name);
     builder.Append("(");
     builder.VisitEnumerable(args);
     builder.Append(")");
 }
开发者ID:netcasewqs,项目名称:elinq,代码行数:7,代码来源:StandardFunctionView.cs


示例8: Render

        public void Render(ISqlBuilder builder, params Expression[] args)
        {
            if (args == null || (args.Length != 2 && args.Length != 3))
            {
                throw new NotSupportedException(string.Format(Res.ArgumentCountError, "substring", "", "2 or 3"));
            }
            builder.Append("CASE WHEN LENGTH(");
            builder.Visit(args[1]);
            builder.Append(") > LENGTH(");
            builder.Visit(args[0]);
            builder.Append(") THEN NULL ELSE SUBSTR(");
            builder.Visit(args[0]);
            builder.Append(",").Visit(args[1]);
            if (args.Length == 2)
            {
                builder.Append(",LENGTH(").Visit(args[0]);
                builder.Append(")");

            }
            else
            {
                builder.Append(",").Visit(args[2]);
            }
            builder.Append(") END");
        }
开发者ID:netcasewqs,项目名称:elinq,代码行数:25,代码来源:SubstringFunctionView.cs


示例9: Render

        public void Render(ISqlBuilder visitor, params Expression[] args)
        {
            var whens = (args[0] as ICollection<Expression>).ToArray();
            var thens = (args[1] as ICollection<Expression>).ToArray();
            var @else = args[2] as Expression;

            var lenght = whens.Length;
            for (int i = 0; i < lenght; i++)
            {
                if (i != 0)
                    visitor.Append(",");

                visitor.Append("IIF(");
                visitor.Visit(whens[i]);
                visitor.Append(",");
                visitor.Visit(thens[i]);

                if (i == lenght - 1)
                {
                    if (@else != null)
                    {
                        visitor.Append(",");
                        visitor.Visit(@else);
                    }
                    for (var j = i; j >= 0; j--)
                        visitor.Append(")");

                }

            }
        }
开发者ID:CMONO,项目名称:elinq,代码行数:31,代码来源:IFFunctionView.cs


示例10: Render

 public virtual void Render(ISqlBuilder visitor, params Expression[] args)
 {
     var targetArg = args[0];
     visitor.Append("RTRIM(LTRIM(");
     visitor.Visit(targetArg);
     visitor.Append("))");
 }
开发者ID:jaykizhou,项目名称:elinq,代码行数:7,代码来源:LRTrimFunctionView.cs


示例11: SetupTest

 public void SetupTest()
 {
     _sqlBuilder = MockRepository.GenerateMock<ISqlBuilder>();
     _paramMgr = MockRepository.GenerateMock<IParameterManager>();
     _queryBuilder = new QueryBuilder( _sqlBuilder, _paramMgr );
     _result = _queryBuilder.Add( _inputSql );
 }
开发者ID:StarTrekRedneck,项目名称:IDbEz,代码行数:7,代码来源:QueryBuilderSpecs.cs


示例12: Render

 public void Render(ISqlBuilder builder, params Expression[] args)
 {
     //SUBSTRING(userName,1,2)+'ddd'+SUBSTRING(userName,3,LEN(userName))
     if (args.Length != 3)
     {
         throw new NotSupportedException(string.Format(Res.ArgumentCountError, "Insert", "", "3"));
     }
     //var secondStartIndex = Expression.Constant((int)(args[1] as ConstantExpression).Value + 1);
     builder.Append("(CASE WHEN ");
     builder.Visit(args[1]);
     builder.Append(" > LEN(");
     builder.Visit(args[0]);
     builder.Append(") THEN null ELSE (SUBSTRING(");
     builder.Visit(args[0]);
     builder.Append(",1,");
     builder.Visit(Expression.Subtract(Expression.Property(args[1], "Value"), Expression.Constant(1, Types.Int32)));
     builder.Append(") + ");
     builder.Visit(args[2]);
     builder.Append(" + SUBSTRING(");
     builder.Visit(args[0]);
     builder.Append(",");
     builder.Visit(args[1]);
     builder.Append(",LEN(");
     builder.Visit(args[0]);
     builder.Append("))) END)");
 }
开发者ID:netcasewqs,项目名称:elinq,代码行数:26,代码来源:InsertFunctionView.cs


示例13: Render

 public void Render(ISqlBuilder ctx, params Expression[] args)
 {
     if (args.Length != 3)
     {
         throw new NotSupportedException(string.Format(Res.ArgumentCountError, "Insert", "", "3"));
     }
     var secondStartIndex = args[1];// Expression.Constant((int)(args[1] as ConstantExpression).Value + 1);
     ctx.Append("(CASE WHEN ");
     ctx.Visit(secondStartIndex);
     ctx.Append(" > LENGTH(");
     ctx.Visit(args[0]);
     ctx.Append(") THEN null ELSE (SUBSTR(");
     ctx.Visit(args[0]);
     ctx.Append(",1,");
     ctx.Visit(Expression.Subtract(Expression.Property(args[1], "Value"), Expression.Constant(1, Types.Int32)));
     ctx.Append(") || ");
     ctx.Visit(args[2]);
     ctx.Append(" || SUBSTR(");
     ctx.Visit(args[0]);
     ctx.AppendFormat(",");
     ctx.Visit(secondStartIndex);
     ctx.Append(",LENGTH(");
     ctx.Visit(args[0]);
     ctx.Append(")))END)");
 }
开发者ID:CMONO,项目名称:elinq,代码行数:25,代码来源:InsertFunctionView.cs


示例14: SqlStatementFormatter

 internal SqlStatementFormatter(EntityDescriptor mainEntityDescriptor, EntityMapping mainEntityMapping, ISqlBuilder mainEntitySqlBuilder)
 {
     this.MainEntityType = mainEntityDescriptor.EntityType;
     this.MainEntityDescriptor = mainEntityDescriptor;
     this.MainEntitySqlBuilder = mainEntitySqlBuilder;
     this.MainEntityMapping = mainEntityMapping;
 }
开发者ID:ingvirafn,项目名称:Dapper.FastCRUD,代码行数:7,代码来源:SqlStatementFormatter.cs


示例15: SqlStatementFormatter

 /// <summary>
 /// Default constructor.
 /// </summary>
 /// <param name="mainEntityDescriptor">Main entity descriptor</param>
 /// <param name="mainEntityMapping">Main entity mappings</param>
 /// <param name="mainEntitySqlBuilder">SQL mapper for the main entity</param>
 /// <param name="forceColumnAsTableColumnResolution">If true, the format identifier 'C' will be treated as 'TC' </param>
 internal SqlStatementFormatter(EntityDescriptor mainEntityDescriptor, EntityMapping mainEntityMapping, ISqlBuilder mainEntitySqlBuilder, bool forceColumnAsTableColumnResolution)
 {
     _forceColumnAsTableColumnResolution = forceColumnAsTableColumnResolution;
     this.MainEntityType = mainEntityDescriptor.EntityType;
     this.MainEntityDescriptor = mainEntityDescriptor;
     this.MainEntitySqlBuilder = mainEntitySqlBuilder;
     this.MainEntityMapping = mainEntityMapping;            
 }
开发者ID:CameronFiederer,项目名称:Dapper.FastCRUD,代码行数:15,代码来源:SqlStatementFormatter.cs


示例16: Render

        public void Render(ISqlBuilder builder, params Expression[] args)
        {
            if (args != null && args.Length > 0)
                throw new ArgumentException(string.Format(Res.ArgumentCountError, Name, "no", ""));

            builder.Append(Name);
            builder.Append("()");
        }
开发者ID:netcasewqs,项目名称:elinq,代码行数:8,代码来源:NoArgFunctionView.cs


示例17: Render

        public void Render(ISqlBuilder builder, params Expression[] args)
        {
            if (args == null)
                throw new NotSupportedException("args");
            if (args.Length != 2 && args.Length != 3)
                throw new NotSupportedException(string.Format(Res.ArgumentCountError, "LastIndexOf", "", "2 or 3"));
            builder.Append("CASE WHEN INSTR(");
            builder.Visit(args[0]);
            builder.Append(",");
            builder.Visit(args[1]);
            builder.Append(") = 0 then  -1  else");
            if (args.Length == 3)
            {
                builder.Append("(CASE WHEN (INSTR(");
                builder.Append("SUBSTRING(");
                builder.Visit(args[0]);
                builder.Append(",1,");
                //args[2] = Expression.Subtract(Expression.Property(args[2], "Value"), Expression.Constant(1, Types.Int32));
                builder.Visit(args[2]);
                builder.Append("),");
                builder.Visit(args[1]);

                builder.Append(")) = 0 or (");
                builder.Visit(args[2]);
                builder.Append(" > LENGTH(");
                builder.Visit(args[0]);
                builder.Append(")) THEN -1 ELSE LENGTH(SUBSTRING(");

                builder.Visit(args[0]);
                builder.Append(",1,");
                builder.Visit(args[2]);
                builder.Append(")) - (INSTR(");
                builder.Append("REVERSE(SUBSTRING(");
                builder.Visit(args[0]);
                builder.Append(",1,");
                builder.Visit(args[2]);
                builder.Append(")),");
                builder.Append("REVERSE(");
                builder.Visit(args[1]);
                builder.Append(")) + LENGTH(");
                builder.Visit(args[1]);
                builder.Append(") -1) END ) END");

            }
            else
            {
                builder.Append("  (LENGTH(");
                builder.Visit(args[0]);
                builder.Append(")- (INSTR(");
                builder.Append("REVERSE(");
                builder.Visit(args[0]);
                builder.Append("),REVERSE(");
                builder.Visit(args[1]);
                builder.Append(")) + LENGTH(");
                builder.Visit(args[1]);
                builder.Append(") - 1)) END");
            }
        }
开发者ID:CMONO,项目名称:elinq,代码行数:58,代码来源:LastIndexOfFunctionView.cs


示例18: Render

        public void Render(ISqlBuilder builder, params Expression[] args)
        {
            if (args == null)
                throw new NotSupportedException("args");
            if (args.Length != 2 && args.Length != 3)
                throw new NotSupportedException(string.Format(Res.ArgumentCountError, "LastIndexOf()", "", " 2 or 3 "));
            //var isChar = args[1].Type == Types.Char;
            builder.Append("IIF(INSTR(");
            builder.Visit(args[0]);
            builder.Append(",");
            builder.Visit(args[1]);
            builder.Append(") = 0,-1,");
            if (args.Length == 3)
            {
                //args[2] = Expression.Constant((int)(args[2] as ConstantExpression).Value + 1);
                builder.Append("(IIf((INSTR(");
                builder.Append("MID(");
                builder.Visit(args[0]);
                builder.Append(",1,");
                builder.Visit(args[2]);
                builder.Append("),");
                builder.Visit(args[1]);
                builder.Append(") = 0) OR (");
                builder.Visit(args[2]);
                builder.Append(" > LEN(");
                builder.Visit(args[0]);
                builder.Append(")),-1 ,(LEN(MID(");
                builder.Visit(args[0]);
                builder.Append(",1,");
                builder.Visit(args[2]);
                builder.Append(")) - (INSTR(");
                builder.Append("STRREVERSE(MID(");
                builder.Visit(args[0]);
                builder.Append(",1,");
                builder.Visit(args[2]);
                builder.Append(")),");

                builder.Append("STRREVERSE(");
                builder.Visit(args[1]);
                builder.Append(")) + LEN(");
                builder.Visit(args[1]);
                builder.Append(")-1)))))");

            }
            else
            {
                builder.Append("(LEN(");
                builder.Visit(args[0]);
                builder.Append(")- (INSTR(STRREVERSE(");
                builder.Visit(args[0]);
                builder.Append("),STRREVERSE(");
                builder.Visit(args[1]);
                builder.Append(")) + LEN(");
                builder.Visit(args[1]);
                builder.Append(")-1)))");

            }
        }
开发者ID:CMONO,项目名称:elinq,代码行数:58,代码来源:LastIndexOfFunction.cs


示例19: Render

 public void Render(ISqlBuilder builder, params Expression[] args)
 {
     var datePart = (DateParts)(args[0] as ConstantExpression).Value;
     IFunctionView f;
     if (functions.TryGetValue(datePart, out f))
         f.Render(builder, args[1], args[2]);
     else
         throw new NotSupportedException(string.Format(Res.NotSupported, "The 'DatePart." + datePart, ""));
 }
开发者ID:jaykizhou,项目名称:elinq,代码行数:9,代码来源:DateDiffFunctionView.cs


示例20: QueryBuilder

 public QueryBuilder()
 {
     ExpressionLanguageParser = ObjectFactory.Get<IExpressionLanguageParser>();
     ExpressionDispatcher = ObjectFactory.Get<IExpressionDispatcher>();
     PrequelAnalyzer = ObjectFactory.Get<IPrequelAnalyzer>();
     ExpressionOptimizer = ObjectFactory.Get<IExpressionOptimizer>();
     SpecialExpressionTranslator = ObjectFactory.Get<ISpecialExpressionTranslator>();
     SqlBuilder = ObjectFactory.Get<ISqlBuilder>();
 }
开发者ID:TheRealDuckboy,项目名称:mono-soc-2008,代码行数:9,代码来源:QueryBuilder.cs



注:本文中的ISqlBuilder类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C# ISqlDialect类代码示例发布时间:2022-05-24
下一篇:
C# ISqlAstVisitor类代码示例发布时间:2022-05-24
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap