本文整理汇总了C#中ISqlDialect.IndexOf方法的典型用法代码示例。如果您正苦于以下问题:C# ISqlDialect.IndexOf方法的具体用法?C# ISqlDialect.IndexOf怎么用?C# ISqlDialect.IndexOf使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ISqlDialect
的用法示例。
在下文中一共展示了ISqlDialect.IndexOf方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: ProcessCallExpression
static string ProcessCallExpression(ISqlDialect dialect, Expression rootExpression, MethodCallExpression e, IDictionary<string, object> parameters, Func<string> getParameterName)
{
var method = e.Method;
string memberName = null;
if (e.Object is ParameterExpression)
{
// This is used by DynamicSQLinqLambdaExpression
memberName = "{FieldName}";
}
else if (e.Object is ConstantExpression)
{
throw new Exception("SqlExpressionCompiler.ProcessCallExpresion: ConstantExpression Unsupported");
}
else if (e.Object != null)
{
// Get Column Name to Use
var member = (MemberInfo)((dynamic)e.Object).Member;
memberName = GetMemberColumnName(member, dialect);
}
if (method.DeclaringType == typeof(Guid))
{
var parameterName = getParameterName();
switch (method.Name.ToLower())
{
case "newguid":
parameters.Add(parameterName, Guid.NewGuid());
return string.Format("{0}{1}", memberName, parameterName);
default:
throw new Exception("Unsupported Method Name (" + method.Name + ") on Guid object");
}
}
else if (method.DeclaringType == typeof(string))
{
string parameterName = null;
string secondParameterName = null;
if (e.Arguments.Count > 0)
{
parameterName = GetExpressionValue(dialect, rootExpression, e.Arguments[0], parameters, getParameterName);
if (e.Arguments.Count > 1)
{
secondParameterName = GetExpressionValue(dialect, rootExpression, e.Arguments[1], parameters, getParameterName);
}
}
switch (method.Name.ToLower())
{
case "startswith":
parameters[parameterName] = parameters[parameterName].ToString() + "%";
return string.Format("{0} LIKE {1}", memberName, parameterName);
case "endswith":
parameters[parameterName] = "%" + parameters[parameterName].ToString();
return string.Format("{0} LIKE {1}", memberName, parameterName);
case "contains":
parameters[parameterName] = "%" + parameters[parameterName].ToString() + "%";
return string.Format("{0} LIKE {1}", memberName, parameterName);
case "toupper":
return dialect.ToUpper(memberName);
case "tolower":
return dialect.ToLower(memberName);
case "replace":
return string.Format("REPLACE({0}, {1}, {2})", memberName, parameterName, secondParameterName);
case "substring":
if (secondParameterName != null)
{
return string.Format("SUBSTR({0}, {1}, {2})", memberName, parameterName, secondParameterName);
}
else
{
return string.Format("SUBSTR({0}, {1})", memberName, parameterName);
}
case "indexof":
return dialect.IndexOf(memberName, parameterName);
case "trim":
return dialect.Trim(memberName);
default:
throw new Exception("Unsupported Method Name (" + method.Name + ") on String object");
}
}
else
throw new Exception("Unsupported Method Declaring Type (" + method.DeclaringType.Name + ")");
}