本文整理汇总了C#中IQueryContext.IgnoreIdentifiersCase方法的典型用法代码示例。如果您正苦于以下问题:C# IQueryContext.IgnoreIdentifiersCase方法的具体用法?C# IQueryContext.IgnoreIdentifiersCase怎么用?C# IQueryContext.IgnoreIdentifiersCase使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类IQueryContext
的用法示例。
在下文中一共展示了IQueryContext.IgnoreIdentifiersCase方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: MatchesInvoke
internal override bool MatchesInvoke(Invoke invoke, IQueryContext queryContext)
{
if (invoke == null)
return false;
bool ignoreCase = true;
if (queryContext != null)
ignoreCase = queryContext.IgnoreIdentifiersCase();
if (!RoutineName.Equals(invoke.RoutineName, ignoreCase))
return false;
var inputParams = Parameters.Where(parameter => parameter.IsInput).ToList();
if (invoke.Arguments.Length != inputParams.Count)
return false;
for (int i = 0; i < invoke.Arguments.Length; i++) {
// TODO: support variable evaluation here? or evaluate parameters before reaching here?
if (!invoke.Arguments[i].IsConstant())
return false;
var argType = invoke.Arguments[i].ReturnType(queryContext, null);
var paramType = Parameters[i].Type;
// TODO: verify if this is assignable (castable) ...
if (!paramType.IsComparable(argType))
return false;
}
return true;
}
示例2: Default
public static ColumnChecker Default(IQueryContext context, ObjectName tableName)
{
var table = context.GetTable(tableName);
if (table == null)
throw new InvalidOperationException(String.Format("Table '{0}' not found in the context.", tableName));
var tableInfo = table.TableInfo;
var ignoreCase = context.IgnoreIdentifiersCase();
return new DefaultChecker(tableInfo, ignoreCase);
}
示例3: Authenticate
protected virtual bool Authenticate(string defaultSchema, string username, string password)
{
if (CurrentState == ConnectorState.Authenticated &&
QueryContext != null)
throw new InvalidOperationException("Already authenticated.");
// TODO: Log a debug information
// TODO: Log an information about the logging user...
try {
QueryContext = OnAuthenticate(defaultSchema, username, password);
if (QueryContext == null)
return false;
QueryContext.AutoCommit(autoCommit);
QueryContext.IgnoreIdentifiersCase(ignoreIdentifiersCase);
QueryContext.ParameterStyle(parameterStyle);
ChangeState(ConnectorState.Authenticated);
return true;
} catch (Exception e) {
// TODO: throw server error
throw;
}
}
示例4: Create
public static QueryExpressionFrom Create(IQueryContext context, SqlQueryExpression expression)
{
// Get the 'from_clause' from the table expression
var fromClause = expression.FromClause;
var ignoreCase = context.IgnoreIdentifiersCase();
var queryFrom = new QueryExpressionFrom(ignoreCase);
foreach (var fromTable in fromClause.AllTables) {
var uniqueKey = fromTable.UniqueKey;
var alias = fromTable.Alias;
if (fromTable.IsSubQuery) {
// eg. FROM ( SELECT id FROM Part )
var subQuery = fromTable.SubQuery;
var subQueryFrom = Create(context, subQuery);
// The aliased name of the table
ObjectName aliasTableName = null;
if (alias != null)
aliasTableName = new ObjectName(alias);
// Add to list of sub-query tables to add to command,
queryFrom.AddTable(new FromTableSubQuerySource(ignoreCase, uniqueKey, subQuery, subQueryFrom, aliasTableName));
} else {
// Else must be a standard command table,
string name = fromTable.Name;
// Resolve to full table name
var tableName = context.ResolveTableName(name);
if (!context.TableExists(tableName))
throw new InvalidOperationException(String.Format("Table '{0}' was not found.", tableName));
ObjectName givenName = null;
if (alias != null)
givenName = new ObjectName(alias);
// Get the ITableQueryInfo object for this table name (aliased).
ITableQueryInfo tableQueryInfo = context.GetTableQueryInfo(tableName, givenName);
queryFrom.AddTable(new FromTableDirectSource(ignoreCase, tableQueryInfo, uniqueKey, givenName, tableName));
}
}
// Set up functions, aliases and exposed variables for this from set,
foreach (var selectColumn in expression.SelectColumns) {
// Is this a glob? (eg. Part.* )
if (selectColumn.IsGlob) {
// Find the columns globbed and add to the 'selectedColumns' result.
if (selectColumn.IsAll) {
queryFrom.ExposeAllColumns();
} else {
// Otherwise the glob must be of the form '[table name].*'
queryFrom.ExposeColumns(selectColumn.TableName);
}
} else {
// Otherwise must be a standard column reference. Note that at this
// time we aren't sure if a column expression is correlated and is
// referencing an outer source. This means we can't verify if the
// column expression is valid or not at this point.
// If this column is aliased, add it as a function reference to the
// select expression
string alias = selectColumn.Alias;
var v = selectColumn.Expression.AsReferenceName();
bool aliasMatchV = (v != null && alias != null &&
queryFrom.CompareStrings(v.Name, alias));
if (alias != null && !aliasMatchV) {
queryFrom.AddExpression(new ExpressionReference(selectColumn.Expression, alias));
queryFrom.ExposeColumn(new ObjectName(alias));
} else if (v != null) {
var resolved = queryFrom.ResolveReference(v);
queryFrom.ExposeColumn(resolved ?? v);
} else {
string funName = selectColumn.Expression.ToString();
queryFrom.AddExpression(new ExpressionReference(selectColumn.Expression, funName));
queryFrom.ExposeColumn(new ObjectName(funName));
}
}
}
return queryFrom;
}
示例5: CheckColumnNamesMatch
public bool CheckColumnNamesMatch(IQueryContext db, String col1, String col2)
{
var comparison = db.IgnoreIdentifiersCase() ? StringComparison.OrdinalIgnoreCase : StringComparison.Ordinal;
return col1.Equals(col2, comparison);
}
示例6: MatchesInvoke
internal override bool MatchesInvoke(Invoke request, IQueryContext queryContext)
{
if (request == null)
return false;
bool ignoreCase = true;
if (queryContext != null)
ignoreCase = queryContext.IgnoreIdentifiersCase();
if (!RoutineName.Equals(request.RoutineName, ignoreCase))
return false;
// TODO: add a better resolution to obtain the final type of the argument
// and compare it to the parameter type definition
bool unboundedSeen = false;
for (int i = 0; i < request.Arguments.Length; i++) {
var argType = request.Arguments[i].ReturnType(queryContext, null);
if (i + 1 > Parameters.Length) {
if (!unboundedSeen)
return false;
// TODO: verify the type of the argument (how to evaluate?)
} else {
var param = Parameters[i];
unboundedSeen = param.IsUnbounded;
var paramType = param.Type;
if (!paramType.IsComparable(argType))
return false;
}
}
if (!unboundedSeen &&
request.Arguments.Length != Parameters.Length)
return false;
return true;
}
示例7: Evaluate
private DataObject Evaluate(SqlExpression expression, IQueryContext queryContext)
{
var ignoreCase = queryContext.IgnoreIdentifiersCase();
// Resolve any variables to the table_def for this expression.
expression = Table.TableInfo.ResolveColumns(ignoreCase, expression);
// Get the variable resolver and evaluate over this data.
IVariableResolver vresolver = VariableResolver;
var reduced = expression.Evaluate(queryContext, vresolver, null);
if (reduced.ExpressionType != SqlExpressionType.Constant)
throw new InvalidOperationException("The DEFAULT expression of the column cannot be reduced to a constant");
return ((SqlConstantExpression) reduced).Value;
}