public PropertyPathTraverser(SqlEmitter sqlEmitter)
        {
            this.sqlEmitter = sqlEmitter;

            joinTree = new JoinTree(this);

            joinTree.TableMap = sqlEmitter.RootClassMap.MustGetTableMap();
        }
        public virtual string ToScalarSql(string npath, Type type, ref IList outParameters, IList inParameters)
        {
            NPathParser parser = new NPathParser() ;
            NPathSelectQuery query = parser.ParseSelectQuery(npath, inParameters) ;

            IClassMap rootClassMap = this.Context.DomainMap.MustGetClassMap(type);

            this.ResultParameters = new ArrayList();

            SqlEmitter sqlEmitter = new SqlEmitter(this, query,NPathQueryType.SelectScalar, rootClassMap);

            string sql = sqlEmitter.EmitSql();

            outParameters = sqlEmitter.ResultParameters;

            return sql;
        }
Пример #3
0
		private SqlExpression EvalSubQuery(NPathSelectQuery subQuery)
		{
			NPathClassName className = (NPathClassName) subQuery.From.Classes[0];
			string collectionProperty = className.Name;
			IPropertyMap rootPropertyMap = this.RootClassMap.MustGetPropertyMap(collectionProperty);

			if (!rootPropertyMap.IsCollection)
				throw new Exception(string.Format("Property '{0}' or type {1} is not a collection",rootPropertyMap.Name, className.Name) ) ;

			IPropertyMap inversePropertyMap = rootPropertyMap.GetInversePropertyMap();
			string dataType = rootPropertyMap.ItemType;
			className.Name = dataType;
			IClassMap classMap = RootClassMap.DomainMap.MustGetClassMap(dataType);
			SqlEmitter subEmitter = new SqlEmitter(this.NPathEngine,subQuery,NPathQueryType.SelectTable,classMap,this.Select,inversePropertyMap,this.subQueryLevel + 1) ;
			SqlSelectStatement subSelect = subEmitter.BuildSqlDom();
			
			return subSelect;
		}