本文整理汇总了C#中SqlGenerator.Visit方法的典型用法代码示例。如果您正苦于以下问题:C# SqlGenerator.Visit方法的具体用法?C# SqlGenerator.Visit怎么用?C# SqlGenerator.Visit使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类SqlGenerator
的用法示例。
在下文中一共展示了SqlGenerator.Visit方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: VisitDbIsNullExpression_variable_size_string_parameter_with_max_length_is_not_cast
public static void VisitDbIsNullExpression_variable_size_string_parameter_with_max_length_is_not_cast()
{
var primitiveType = PrimitiveType.GetEdmPrimitiveType(PrimitiveTypeKind.String);
var typeUsage = TypeUsage.CreateStringTypeUsage(primitiveType, isUnicode: true, isFixedLength: false, maxLength: 100);
var isNullExpression = typeUsage.Parameter("parameterName").IsNull();
var sqlGenerator = new SqlGenerator();
var sqlFragment = sqlGenerator.Visit(isNullExpression);
var builder = new StringBuilder();
using (var writer = new SqlWriter(builder))
{
sqlFragment.WriteSql(writer, sqlGenerator);
}
Assert.Equal("@parameterName IS NULL", builder.ToString());
}
示例2: VisitDbIsNullExpression_variable_size_binary_parameter_without_max_length_is_cast_to_image
public static void VisitDbIsNullExpression_variable_size_binary_parameter_without_max_length_is_cast_to_image()
{
var primitiveType = PrimitiveType.GetEdmPrimitiveType(PrimitiveTypeKind.Binary);
var typeUsage = TypeUsage.CreateBinaryTypeUsage(primitiveType, isFixedLength: false);
var isNullExpression = typeUsage.Parameter("parameterName").IsNull();
var sqlGenerator = new SqlGenerator();
var sqlFragment = sqlGenerator.Visit(isNullExpression);
var builder = new StringBuilder();
using (var writer = new SqlWriter(builder))
{
sqlFragment.WriteSql(writer, sqlGenerator);
}
Assert.Equal("cast(@parameterName as image) IS NULL", builder.ToString());
}
示例3: VisitDbIsNullExpression_non_parameter_reference_expression_is_not_cast
public static void VisitDbIsNullExpression_non_parameter_reference_expression_is_not_cast()
{
var primitiveType = PrimitiveType.GetEdmPrimitiveType(PrimitiveTypeKind.String);
var typeUsage = TypeUsage.CreateStringTypeUsage(primitiveType, isUnicode: true, isFixedLength: false);
var isNullExpression = typeUsage.Constant("constant").IsNull();
var sqlGenerator = new SqlGenerator();
var sqlFragment = sqlGenerator.Visit(isNullExpression);
var builder = new StringBuilder();
using (var writer = new SqlWriter(builder))
{
sqlFragment.WriteSql(writer, sqlGenerator);
}
Assert.Equal("N'constant' IS NULL", builder.ToString());
}
示例4: Visit_In_expression_with_empty_list_and_Visit_Constant_expression_false_generate_same_sql
public void Visit_In_expression_with_empty_list_and_Visit_Constant_expression_false_generate_same_sql()
{
var generator = new SqlGenerator();
var inExpression = DbExpressionBuilder.In(
DbExpressionBuilder.Constant(5), new List<DbConstantExpression>());
var builder1 = new StringBuilder();
var builder2 = new StringBuilder();
using (var writer = new SqlWriter(builder1))
{
generator.Visit(DbExpressionBuilder.False).WriteSql(writer, null);
}
using (var writer = new SqlWriter(builder2))
{
generator.Visit(inExpression).WriteSql(writer, null);
}
Assert.Equal(builder1.ToString(), builder2.ToString());
}