本文整理汇总了C#中ISqlBuilder类的典型用法代码示例。如果您正苦于以下问题:C# ISqlBuilder类的具体用法?C# ISqlBuilder怎么用?C# ISqlBuilder使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
ISqlBuilder类属于命名空间,在下文中一共展示了ISqlBuilder类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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)))");
}
示例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(") = '')");
}
}
示例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");
}
示例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(")");
}
示例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");
}
示例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(",''))");
}
示例7: Render
public virtual void Render(ISqlBuilder builder, params Expression[] args)
{
builder.Append(name);
builder.Append("(");
builder.VisitEnumerable(args);
builder.Append(")");
}
示例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");
}
示例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(")");
}
}
}
示例10: Render
public virtual void Render(ISqlBuilder visitor, params Expression[] args)
{
var targetArg = args[0];
visitor.Append("RTRIM(LTRIM(");
visitor.Visit(targetArg);
visitor.Append("))");
}
示例11: SetupTest
public void SetupTest()
{
_sqlBuilder = MockRepository.GenerateMock<ISqlBuilder>();
_paramMgr = MockRepository.GenerateMock<IParameterManager>();
_queryBuilder = new QueryBuilder( _sqlBuilder, _paramMgr );
_result = _queryBuilder.Add( _inputSql );
}
示例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)");
}
示例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)");
}
示例14: SqlStatementFormatter
internal SqlStatementFormatter(EntityDescriptor mainEntityDescriptor, EntityMapping mainEntityMapping, ISqlBuilder mainEntitySqlBuilder)
{
this.MainEntityType = mainEntityDescriptor.EntityType;
this.MainEntityDescriptor = mainEntityDescriptor;
this.MainEntitySqlBuilder = mainEntitySqlBuilder;
this.MainEntityMapping = mainEntityMapping;
}
示例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;
}