public override IType[] GetTypes(ICriteria criteria, ICriteriaQuery criteriaQuery) { IType[] trueTypes = whenTrue.GetTypes(criteria, criteriaQuery); IType[] falseTypes = whenFalse.GetTypes(criteria, criteriaQuery); bool areEqual = trueTypes.Length == falseTypes.Length; if (areEqual) { for (int i = 0; i < trueTypes.Length; i++) { if (trueTypes[i].ReturnedClass != falseTypes[i].ReturnedClass) { areEqual = false; break; } } } if (areEqual == false) { string msg = "Both true and false projections must return the same types." + Environment.NewLine + "But True projection returns: [" + string.Join <IType>(", ", trueTypes) + "] " + Environment.NewLine + "And False projection returns: [" + string.Join <IType>(", ", falseTypes) + "]"; throw new HibernateException(msg); } return(trueTypes); }
public IType GetTypeUsingProjection(ICriteria subcriteria, string propertyName) { //first look for a reference to a projection alias IProjection projection = rootCriteria.Projection; IType[] projectionTypes = projection == null ? null : projection.GetTypes(propertyName, subcriteria, this); if (projectionTypes == null) { //it does not refer to an alias of a projection, //look for a property if (TryGetType(subcriteria, propertyName, out var type)) { return(type); } if (outerQueryTranslator != null) { return(outerQueryTranslator.GetTypeUsingProjection(subcriteria, propertyName)); } throw new QueryException("Could not find property " + propertyName); } else { if (projectionTypes.Length != 1) { //should never happen, i think throw new QueryException("not a single-length projection: " + propertyName); } return(projectionTypes[0]); } }
private IType GetReturnType(ICriteria criteria, ICriteriaQuery criteriaQuery) { ISQLFunction sqlFunction = GetFunction(criteriaQuery); var resultType = returnType ?? returnTypeProjection?.GetTypes(criteria, criteriaQuery).FirstOrDefault(); return(sqlFunction.GetReturnType(new[] { resultType }, criteriaQuery.Factory, true)); }
public override IType[] GetTypes(ICriteria criteria, ICriteriaQuery criteriaQuery) { if (projection != null) { return(projection.GetTypes(criteria, criteriaQuery)); } return(new IType[] { criteriaQuery.GetType(criteria, propertyName) }); }
private SqlType[] SqlTypes(ICriteria criteria, ICriteriaQuery criteriaQuery) { var type = projection == null ? criteriaQuery.GetTypeUsingProjection(criteria, propertyName) : projection.GetTypes(criteria, criteriaQuery)[0]; return(type.SqlTypes(criteriaQuery.Factory)); }
/// <summary> /// Determine the type of the elements in the IN clause. /// </summary> private IType GetElementType(ICriteria criteria, ICriteriaQuery criteriaQuery) { if (_projection == null) { return(criteriaQuery.GetTypeUsingProjection(criteria, _propertyName)); } IType[] types = _projection.GetTypes(criteria, criteriaQuery); if (types.Length != 1) { throw new QueryException("Cannot use projections that return more than a single column with InExpression"); } return(types[0]); }
public override TypedValue[] GetTypedValues(ICriteria criteria, ICriteriaQuery criteriaQuery) { List <TypedValue> list = new List <TypedValue>(); IType type; if (_projection == null) { type = criteriaQuery.GetTypeUsingProjection(criteria, _propertyName); } else { IType[] types = _projection.GetTypes(criteria, criteriaQuery); if (types.Length != 1) { throw new QueryException("Cannot use projections that return more than a single column with InExpression"); } type = types[0]; list.AddRange(_projection.GetTypedValues(criteria, criteriaQuery)); } if (type.IsComponentType) { IAbstractComponentType actype = (IAbstractComponentType)type; IType[] types = actype.Subtypes; for (int i = 0; i < types.Length; i++) { for (int j = 0; j < _values.Length; j++) { object subval = _values[j] == null ? null : actype.GetPropertyValues(_values[j], EntityMode.Poco)[i]; list.Add(new TypedValue(types[i], subval, EntityMode.Poco)); } } } else { for (int j = 0; j < _values.Length; j++) { list.Add(new TypedValue(type, _values[j], EntityMode.Poco)); } } return(list.ToArray()); }
public override IType[] GetTypes(ICriteria criteria, ICriteriaQuery criteriaQuery) { var elseTypes = _elseProjection.GetTypes(criteria, criteriaQuery); for (var i = 0; i < _cases.Length; i++) { var subsequentTypes = _cases[i].Projection.GetTypes(criteria, criteriaQuery); if (!AreTypesEqual(elseTypes, subsequentTypes)) { string msg = "All projections must return the same types." + Environment.NewLine + "But Else projection returns: [" + string.Join <IType>(", ", elseTypes) + "] " + Environment.NewLine + "And When projection " + i + " returns: [" + string.Join <IType>(", ", subsequentTypes) + "]"; throw new HibernateException(msg); } } return(elseTypes); }
/// <summary> /// Determine the type of the elements in the IN clause. /// </summary> private IType GetElementType(ICriteria criteria, ICriteriaQuery criteriaQuery) { if (_projection == null) //return criteriaQuery.GetTypeUsingProjection(criteria, _propertyName); { //把计㏕﹚肚String篈 if (this._values[0].ToString().Length > 4000) { return(NHibernateUtil.StringClob); } return(NHibernateUtil.String); } IType[] types = _projection.GetTypes(criteria, criteriaQuery); if (types.Length != 1) { throw new QueryException("Cannot use projections that return more than a single column with InExpression"); } return(types[0]); }
public IType GetTypeUsingProjection(ICriteria subcriteria, string propertyName) { //first look for a reference to a projection alias IProjection projection = rootCriteria.Projection; IType[] projectionTypes = projection == null ? null : projection.GetTypes(propertyName, subcriteria, this); if (projectionTypes == null) { try { //it does not refer to an alias of a projection, //look for a property return(GetType(subcriteria, propertyName)); } catch (HibernateException) { //not found in inner query , try the outer query if (outerQueryTranslator != null) { return(outerQueryTranslator.GetType(subcriteria, propertyName)); } else { throw; } } } else { if (projectionTypes.Length != 1) { //should never happen, i think throw new QueryException("not a single-length projection: " + propertyName); } return(projectionTypes[0]); } }
public virtual IType[] GetTypes(ICriteria criteria, ICriteriaQuery criteriaQuery) { return(projection.GetTypes(criteria, criteriaQuery)); }
private static AggregationFunc ToSumFunc(IProjection projection) { var aggregationResultClass = projection.GetTypes(null, null)[0].ReturnedClass; return(AggregationUtil.GetSumFunc(aggregationResultClass)); }