本文整理汇总了C#中ICriteriaQuery.NewQueryParameter方法的典型用法代码示例。如果您正苦于以下问题:C# ICriteriaQuery.NewQueryParameter方法的具体用法?C# ICriteriaQuery.NewQueryParameter怎么用?C# ICriteriaQuery.NewQueryParameter使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ICriteriaQuery
的用法示例。
在下文中一共展示了ICriteriaQuery.NewQueryParameter方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: ToSqlString
public override SqlString ToSqlString(ICriteria criteria, ICriteriaQuery criteriaQuery, IDictionary<string, IFilter> enabledFilters)
{
var sqlBuilder = new SqlStringBuilder();
SqlString[] columnNames = null;
if (_propertyName != "*")
{
columnNames = CriterionUtil.GetColumnNames(_propertyName, _projection, criteriaQuery, criteria, enabledFilters);
if (columnNames.Length != 1)
{
throw new HibernateException("Contains may only be used with single-column properties");
}
} else
{
columnNames = new SqlString[]
{
new SqlString("*")
};
}
sqlBuilder.Add("contains(")
.Add(columnNames[0])
.Add(",");
sqlBuilder.Add(criteriaQuery.NewQueryParameter(GetParameterTypedValue(criteria, criteriaQuery)).Single());
sqlBuilder.Add(")");
return sqlBuilder.ToSqlString();
}
示例2: ToSqlString
public override SqlString ToSqlString(ICriteria criteria, int position, ICriteriaQuery criteriaQuery, IDictionary<string, IFilter> enabledFilters)
{
return new SqlStringBuilder()
.Add(string.Format(" CASE WHEN {0} LIKE ", PropertyName))
.Add(criteriaQuery.NewQueryParameter(new TypedValue(NHibernateUtil.String, string.Format("{0}%", SearchValue), EntityMode.Poco)).Single())
.Add(string.Format(" THEN 0 WHEN {0} LIKE ", PropertyName))
.Add(criteriaQuery.NewQueryParameter(new TypedValue(NHibernateUtil.String, string.Format("% %{0}% %", SearchValue), EntityMode.Poco)).Single())
.Add(string.Format(" THEN 1 WHEN {0} LIKE ", PropertyName))
.Add(criteriaQuery.NewQueryParameter(new TypedValue(NHibernateUtil.String, string.Format("%{0}", SearchValue), EntityMode.Poco)).Single())
.Add(" THEN 2 ELSE 3 END ")
.Add(" as ")
.Add(GetColumnAliases(position)[0])
.ToSqlString();
}
示例3: ToSqlString
public override SqlString ToSqlString(ICriteria criteria, ICriteriaQuery criteriaQuery, IDictionary<string, IFilter> enabledFilters)
{
//TODO: add a default capacity
SqlStringBuilder sqlBuilder = new SqlStringBuilder();
var parametersTypes = GetTypedValues(criteria, criteriaQuery).ToArray();
var lowType = parametersTypes[0];
var highType = parametersTypes[1];
SqlString[] columnNames =
CriterionUtil.GetColumnNames(_propertyName, _projection, criteriaQuery, criteria, enabledFilters);
if (columnNames.Length == 1)
{
sqlBuilder
.Add(columnNames[0])
.Add(" between ")
.Add(criteriaQuery.NewQueryParameter(lowType).Single())
.Add(" and ")
.Add(criteriaQuery.NewQueryParameter(highType).Single());
}
else
{
bool andNeeded = false;
var lowParameters = criteriaQuery.NewQueryParameter(lowType).ToArray();
for (int i = 0; i < columnNames.Length; i++)
{
if (andNeeded)
{
sqlBuilder.Add(" AND ");
}
andNeeded = true;
sqlBuilder.Add(columnNames[i])
.Add(" >= ")
.Add(lowParameters[i]);
}
var highParameters = criteriaQuery.NewQueryParameter(highType).ToArray();
for (int i = 0; i < columnNames.Length; i++)
{
sqlBuilder.Add(" AND ")
.Add(columnNames[i])
.Add(" <= ")
.Add(highParameters[i]);
}
}
return sqlBuilder.ToSqlString();
}
示例4: ToSqlString
public override SqlString ToSqlString(ICriteria criteria, int position, ICriteriaQuery criteriaQuery, IDictionary<string, IFilter> enabledFilters)
{
return new SqlString(
criteriaQuery.NewQueryParameter(typedValue).Single(),
" as ",
GetColumnAliases(position, criteria, criteriaQuery)[0]);
}
示例5: ToSqlString
public override SqlString ToSqlString(ICriteria criteria, ICriteriaQuery criteriaQuery, IDictionary<string, IFilter> enabledFilters)
{
//Implementation changed from H3.2 to use SqlString
string[] columns = criteriaQuery.GetIdentifierColumns(criteria);
Parameter[] parameters = GetTypedValues(criteria, criteriaQuery).SelectMany(t => criteriaQuery.NewQueryParameter(t)).ToArray();
SqlStringBuilder result = new SqlStringBuilder(4 * columns.Length + 2);
if (columns.Length > 1)
{
result.Add(StringHelper.OpenParen);
}
for (int i = 0; i < columns.Length; i++)
{
if (i > 0)
{
result.Add(" and ");
}
result.Add(columns[i])
.Add(" = ");
AddValueOrProjection(parameters, i, criteria, criteriaQuery, enabledFilters, result);
}
if (columns.Length > 1)
{
result.Add(StringHelper.ClosedParen);
}
return result.ToSqlString();
}
示例6: ToSqlString
public override SqlString ToSqlString(ICriteria criteria, int position, ICriteriaQuery criteriaQuery, IDictionary<string, IFilter> enabledFilters)
{
return new SqlStringBuilder()
.Add(criteriaQuery.NewQueryParameter(typedValue).Single())
.Add(" as ")
.Add(GetColumnAliases(position)[0])
.ToSqlString();
}
示例7: ToSqlString
public override SqlString ToSqlString(ICriteria criteria, int position, ICriteriaQuery criteriaQuery, IDictionary<string, IFilter> enabledFilters)
{
var loc = position * GetHashCode();
var val = _projection.ToSqlString(criteria, loc, criteriaQuery, enabledFilters);
val = HierarchyIdStringHelper.RemoveAsAliasesFromSql(val);
var lhs = new SqlStringBuilder();
lhs.Add(val);
lhs.Add(".GetReparentedValue(");
lhs.Add(criteriaQuery.NewQueryParameter(new TypedValue(NHibernateUtil.String, _oldRoot, EntityMode.Poco)).Single());
lhs.Add(" , ");
lhs.Add(criteriaQuery.NewQueryParameter(new TypedValue(NHibernateUtil.String, _newRoot, EntityMode.Poco)).Single());
lhs.Add(") as ");
lhs.Add(GetColumnAliases(position)[0]);
var ret = lhs.ToSqlString();
return ret;
}
示例8: ToSqlString
public override SqlString ToSqlString(ICriteria criteria, ICriteriaQuery criteriaQuery, IDictionary<string, IFilter> enabledFilters)
{
var columnName = Projection.GetColumnName(criteria, criteriaQuery, enabledFilters);
var parameter = criteriaQuery.NewQueryParameter(GetParameterTypedValue()).Single();
return new SqlStringBuilder(3)
.Add(columnName)
.Add(Operation)
.Add(parameter)
.ToSqlString();
}
示例9: ToSqlString
public override SqlString ToSqlString(ICriteria criteria, int position, ICriteriaQuery criteriaQuery, IDictionary<string, IFilter> enabledFilters)
{
string[] projection = criteriaQuery.GetColumnsUsingProjection(criteria, propertyName);
return new SqlStringBuilder()
.Add("(")
.Add(projection[0])
.Add(" + ")
.Add(criteriaQuery.NewQueryParameter(typedValue).Single())
.Add(") as ")
.Add(GetColumnAliases(0, criteria, criteriaQuery)[0])
.ToSqlString();
}
示例10: ToSqlString
public override SqlString ToSqlString(ICriteria criteria, ICriteriaQuery criteriaQuery, IDictionary<string, IFilter> enabledFilters)
{
var parameters = _sql.GetParameters().ToList();
var paramPos = 0;
for (int i = 0; i < _typedValues.Length; i++)
{
var controlledParameters = criteriaQuery.NewQueryParameter(_typedValues[i]);
foreach (Parameter parameter in controlledParameters)
{
parameters[paramPos++].BackTrack = parameter.BackTrack;
}
}
return _sql.Replace("{alias}", criteriaQuery.GetSQLAlias(criteria));
}
示例11: ToSqlString
public override SqlString ToSqlString(ICriteria criteria, ICriteriaQuery criteriaQuery, IDictionary<string, IFilter> enabledFilters)
{
if (_projection == null)
{
AssertPropertyIsNotCollection(criteriaQuery, criteria);
}
if (_values.Length == 0)
{
// "something in ()" is always false
return new SqlString("1=0");
}
//TODO: add default capacity
SqlStringBuilder result = new SqlStringBuilder();
SqlString[] columnNames =
CriterionUtil.GetColumnNames(_propertyName, _projection, criteriaQuery, criteria, enabledFilters);
// Generate SqlString of the form:
// columnName1 in (values) and columnName2 in (values) and ...
Parameter[] parameters = GetTypedValues(criteria, criteriaQuery).SelectMany(t => criteriaQuery.NewQueryParameter(t)).ToArray();
for (int columnIndex = 0; columnIndex < columnNames.Length; columnIndex++)
{
SqlString columnName = columnNames[columnIndex];
if (columnIndex > 0)
{
result.Add(" and ");
}
result
.Add(columnName)
.Add(" in (");
for (int i = 0; i < _values.Length; i++)
{
if (i > 0)
{
result.Add(StringHelper.CommaSpace);
}
result.Add(parameters[i]);
}
result.Add(")");
}
return result.ToSqlString();
}
示例12: ToSqlString
public override SqlString ToSqlString(ICriteria criteria, ICriteriaQuery criteriaQuery,
IDictionary<string, IFilter> enabledFilters)
{
var columns = CriterionUtil.GetColumnNames(_propertyName, _projection, criteriaQuery, criteria,
enabledFilters);
if (columns.Length != 1)
throw new HibernateException(
"IsDescendantOf may only be used with single-column properties / projections.");
var lhs = new SqlStringBuilder(6);
lhs.Add(columns[0]);
lhs.Add(".IsDescendantOf(");
lhs.Add(criteriaQuery.NewQueryParameter(_typedValue).Single());
lhs.Add(") = 1");
return lhs.ToSqlString();
}
示例13: ToSqlString
public override SqlString ToSqlString(ICriteria criteria, ICriteriaQuery criteriaQuery, IDictionary<string, IFilter> enabledFilters)
{
//TODO: add default capacity
SqlStringBuilder sqlBuilder = new SqlStringBuilder();
SqlString[] columnNames =
CriterionUtil.GetColumnNames(propertyName, projection, criteriaQuery, criteria, enabledFilters);
if (columnNames.Length != 1)
{
throw new HibernateException("insensitive like may only be used with single-column properties");
}
if (criteriaQuery.Factory.Dialect is PostgreSQLDialect)
{
sqlBuilder.Add(columnNames[0]);
sqlBuilder.Add(" ilike ");
}
else
{
sqlBuilder.Add(criteriaQuery.Factory.Dialect.LowercaseFunction)
.Add("(")
.Add(columnNames[0])
.Add(")")
.Add(" like ");
}
sqlBuilder.Add(criteriaQuery.NewQueryParameter(GetParameterTypedValue(criteria, criteriaQuery)).Single());
return sqlBuilder.ToSqlString();
}
示例14: ToSqlString
public override SqlString ToSqlString(ICriteria criteria, ICriteriaQuery criteriaQuery, IDictionary<string, IFilter> enabledFilters)
{
SqlString[] columns = CriterionUtil.GetColumnNamesUsingProjection(projection, criteriaQuery, criteria, enabledFilters);
if (columns.Length != 1)
throw new HibernateException("Like may only be used with single-column properties / projections.");
SqlStringBuilder lhs = new SqlStringBuilder(6);
if (ignoreCase)
{
Dialect.Dialect dialect = criteriaQuery.Factory.Dialect;
lhs.Add(dialect.LowercaseFunction)
.Add(StringHelper.OpenParen)
.Add(columns[0])
.Add(StringHelper.ClosedParen);
}
else
lhs.Add(columns[0]);
if (ignoreCase)
{
Dialect.Dialect dialect = criteriaQuery.Factory.Dialect;
lhs.Add(" like ")
.Add(dialect.LowercaseFunction)
.Add(StringHelper.OpenParen)
.Add(criteriaQuery.NewQueryParameter(typedValue).Single())
.Add(StringHelper.ClosedParen);
}
else
lhs.Add(" like ").Add(criteriaQuery.NewQueryParameter(typedValue).Single());
if (escapeChar.HasValue)
lhs.Add(" escape '" + escapeChar + "'");
return lhs.ToSqlString();
}
示例15: ToSqlString
/// <summary>
/// Render the SQL Fragment.
/// </summary>
/// <param name="criteria"></param>
/// <param name="position"></param>
/// <param name="criteriaQuery"></param>
/// <param name="enabledFilters"></param>
/// <returns></returns>
public override SqlString ToSqlString(ICriteria criteria, int position, ICriteriaQuery criteriaQuery, IDictionary<string, IFilter> enabledFilters)
{
var spatialDialect = (ISpatialDialect)criteriaQuery.Factory.Dialect;
string column1 = criteriaQuery.GetColumn(criteria, this.propertyName);
SqlString sqlString;
if (IsBinaryOperation())
{
if (geometry != null)
{
Parameter[] parameters = criteriaQuery.NewQueryParameter(this.GetTypedValues(criteria, criteriaQuery)[0]).ToArray();
sqlString = spatialDialect.GetSpatialAnalysisString(column1, this.analysis, parameters.Single());
}
else
{
string column2 = criteriaQuery.GetColumn(criteria, this.anotherPropertyName);
sqlString = spatialDialect.GetSpatialAnalysisString(column1, this.analysis, column2);
}
}
else
{
sqlString = spatialDialect.GetSpatialAnalysisString(column1, this.analysis, null);
}
return new SqlStringBuilder()
.Add(sqlString)
.Add(" as y")
.Add(position.ToString())
.Add("_")
.ToSqlString();
}