当前位置: 首页>>代码示例>>C#>>正文


C# Classic.QueryTranslator类代码示例

本文整理汇总了C#中NHibernate.Hql.Classic.QueryTranslator的典型用法代码示例。如果您正苦于以下问题:C# QueryTranslator类的具体用法?C# QueryTranslator怎么用?C# QueryTranslator使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


QueryTranslator类属于NHibernate.Hql.Classic命名空间,在下文中一共展示了QueryTranslator类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: End

 public void End(QueryTranslator q)
 {
     if (parenCount > 0 || funcStack.HasFunctions)
     {
         throw new QueryException("close paren missed in SELECT");
     }
 }
开发者ID:zibler,项目名称:zibler,代码行数:7,代码来源:SelectParser.cs

示例2: AppendToken

		protected override void AppendToken(QueryTranslator q, string token)
		{
			// a String.Empty can get passed in here.  If that occurs
			// then don't create a new SqlString for it - just ignore
			// it since it adds nothing to the sql being generated.
			if (token != null && token.Length > 0)
				q.AppendHavingToken(new SqlString(token));
		}
开发者ID:khaliyo,项目名称:Spring.net-NHibernate.net-Asp.net-MVC-DWZ-,代码行数:8,代码来源:HavingParser.cs

示例3: Start

 public void Start(QueryTranslator q)
 {
     readyForAliasOrExpression = true;
     first = true;
     afterNew = false;
     holderClass = null;
     parenCount = 0;
     funcStack = new FunctionStack(q.Factory);
 }
开发者ID:zibler,项目名称:zibler,代码行数:9,代码来源:SelectParser.cs

示例4: Parse

		public static void Parse(IParser p, string text, string seperators, QueryTranslator q)
		{
			StringTokenizer tokens = new StringTokenizer(text, seperators, true);
			p.Start(q);
			foreach (string token in tokens)
			{
				p.Token(token, q);
			}
			p.End(q);
		}
开发者ID:hazzik,项目名称:nh-contrib-everything,代码行数:10,代码来源:ParserHelper.cs

示例5: ContinueFromManyToMany

		public string ContinueFromManyToMany(System.Type clazz, string[] joinColumns, QueryTranslator q)
		{
			Start(q);
			continuation = true;
			currentName = q.CreateNameFor(clazz);
			q.AddType(currentName, clazz);
			IQueryable classPersister = q.GetPersister(clazz);
			AddJoin(currentName, TypeFactory.ManyToOne(clazz), joinColumns);
			currentPropertyMapping = classPersister;
			return currentName;
		}
开发者ID:Novthirteen,项目名称:sconit_timesseiko,代码行数:11,代码来源:PathExpressionParser.cs

示例6: Token

		public void Token(string token, QueryTranslator q)
		{
			if (q.IsName(StringHelper.Root(token)))
			{
				ParserHelper.Parse(pathExpressionParser, q.Unalias(token), ParserHelper.PathSeparators, q);
				q.AppendGroupByToken(pathExpressionParser.WhereColumn);
				pathExpressionParser.AddAssociation(q);
			}
			else
			{
				q.AppendGroupByToken(token);
			}
		}
开发者ID:Novthirteen,项目名称:sconit_timesseiko,代码行数:13,代码来源:GroupByParser.cs

示例7: Token

		public void Token(string token, QueryTranslator q)
		{
			if (q.IsName(StringHelper.Root(token)))
			{
				ParserHelper.Parse(pathExpressionParser, q.Unalias(token), ParserHelper.PathSeparators, q);
				q.AppendGroupByToken(pathExpressionParser.WhereColumn);
				pathExpressionParser.AddAssociation(q);
			}
			else if (token.StartsWith(ParserHelper.HqlVariablePrefix))
			{
				q.AddNamedParameter(token.Substring(1));
				q.AppendGroupByParameter();
			}
			else
			{
				q.AppendGroupByToken(token);
			}
		}
开发者ID:pallmall,项目名称:WCell,代码行数:18,代码来源:GroupByParser.cs

示例8: End

		public override void End(QueryTranslator q)
		{
			if (!IsCollectionValued)
			{
				IType type = PropertyType;
				if (type.IsEntityType)
				{
					// "finish off" the join
					Token(".", q);
					Token(null, q);
				}
				else if (type.IsCollectionType)
				{
					// default to element set if no elements() specified
					Token(".", q);
					Token(CollectionPropertyNames.Elements, q);
				}
			}
			base.End(q);
		}
开发者ID:hazzik,项目名称:nh-contrib-everything,代码行数:20,代码来源:FromPathExpressionParser.cs

示例9: SetType

		private void SetType(QueryTranslator q)
		{
			if (currentProperty == null)
			{
				type = PropertyMapping.Type;
			}
			else
			{
				type = PropertyType;
			}
		}
开发者ID:khaliyo,项目名称:Spring.net-NHibernate.net-Asp.net-MVC-DWZ-,代码行数:11,代码来源:PathExpressionParser.cs

示例10: DereferenceCollection

		private void DereferenceCollection(String propertyName, String role, QueryTranslator q)
		{
			collectionRole = role;
			IQueryableCollection collPersister = q.GetCollectionPersister(role);
			string name = q.CreateNameForCollection(role);
			AddJoin(name, collPersister.CollectionType);

			//if ( collPersister.HasWhere ) 
			//{
			//    join.AddCondition( collPersister.GetSQLWhereString( name ) );
			//}

			collectionName = name;
			collectionOwnerName = currentName;
			currentName = name;
			currentProperty = propertyName;
			componentPath.Length = 0;
			//componentPath = new StringBuilder();
			currentPropertyMapping = new CollectionPropertyMapping(collPersister);
		}
开发者ID:khaliyo,项目名称:Spring.net-NHibernate.net-Asp.net-MVC-DWZ-,代码行数:20,代码来源:PathExpressionParser.cs

示例11: DereferenceEntity

		/// <summary>
		/// 
		/// </summary>
		/// <param name="propertyName"></param>
		/// <param name="propertyType"></param>
		/// <param name="q"></param>
		/// <remarks>NOTE: we avoid joining to the next table if the named property is just the foreign key value</remarks>
		private void DereferenceEntity(string propertyName, EntityType propertyType, QueryTranslator q)
		{
			//if its "id"
			bool isIdShortcut = EntityID.Equals(propertyName) && !propertyType.IsUniqueKeyReference;

			//or its the id property name
			string idPropertyName;
			try
			{
				idPropertyName = propertyType.GetIdentifierOrUniqueKeyPropertyName(q.Factory);
			}
			catch (MappingException me)
			{
				throw new QueryException(me);
			}
			bool isNamedIdPropertyShortcut = idPropertyName != null && idPropertyName.Equals(propertyName);

			if (isIdShortcut || isNamedIdPropertyShortcut)
			{
				// special shortcut for id properties, skip the join!
				// this must only occur at the _end_ of a path expression
				DereferenceProperty(propertyName);
			}
			else
			{
				string entityClass = propertyType.GetAssociatedEntityName();
				string name = q.CreateNameFor(entityClass);
				q.AddType(name, entityClass);
				//String[] keyColNames = memberPersister.getIdentifierColumnNames();
				AddJoin(name, propertyType);
                if (propertyType.IsOneToOne)
                {
                    oneToOneOwnerName = currentName;
                }
                else
                {
                    oneToOneOwnerName = null;
                }
				ownerAssociationType = propertyType;
				currentName = name;
				currentProperty = propertyName;
				q.AddPathAliasAndJoin(path.ToString(0, path.ToString().LastIndexOf(StringHelper.Dot)), name, joinSequence.Copy());
				componentPath.Length = 0;
				currentPropertyMapping = q.GetPersister(entityClass);
			}
		}
开发者ID:khaliyo,项目名称:Spring.net-NHibernate.net-Asp.net-MVC-DWZ-,代码行数:53,代码来源:PathExpressionParser.cs

示例12: Token

		public void Token(string token, QueryTranslator q)
		{
			if (token != null)
			{
				path.Append(token);
			}

			string alias = q.GetPathAlias(path.ToString());
			if (alias != null)
			{
				Reset(q); //reset the dotcount (but not the path)
				currentName = alias; //after reset!
				currentPropertyMapping = q.GetPropertyMapping(currentName);
				if (!ignoreInitialJoin)
				{
					JoinSequence ojf = q.GetPathJoin(path.ToString());
					try
					{
						joinSequence.AddCondition(ojf.ToJoinFragment(q.EnabledFilters, true).ToWhereFragmentString); //after reset!
					}
					catch (MappingException me)
					{
						throw new QueryException(me);
					}
					// we don't need to worry about any condition in the ON clause
					// here (toFromFragmentString), since anything in the ON condition 
					// is already applied to the whole query
				}
			}
			else if (".".Equals(token))
			{
				dotcount++;
			}
			else
			{
				if (dotcount == 0)
				{
					if (!continuation)
					{
						if (!q.IsName(token))
						{
							throw new QueryException("undefined alias or unknown mapping: " + token);
						}
						currentName = token;
						currentPropertyMapping = q.GetPropertyMapping(currentName);
					}
				}
				else if (dotcount == 1)
				{
					if (currentName != null)
					{
						currentProperty = token;
					}
					else if (collectionName != null)
					{
						//IQueryableCollection p = q.GetCollectionPersister( collectionRole );
						//DoCollectionProperty( token, p, collectionName );
						continuation = false;
					}
					else
					{
						throw new QueryException("unexpected");
					}
				}
				else
				{
					// dotcount>=2

					// Do the corresponding RHS
					IType propertyType = PropertyType;

					if (propertyType == null)
					{
						throw new QueryException("unresolved property: " + currentProperty);
					}

					if (propertyType.IsComponentType)
					{
						DereferenceComponent(token);
					}
					else if (propertyType.IsEntityType)
					{
						DereferenceEntity(token, (EntityType) propertyType, q);
					}
					else if (propertyType.IsCollectionType)
					{
						DereferenceCollection(token, ((CollectionType) propertyType).Role, q);
					}
					else if (token != null)
					{
						throw new QueryException("dereferenced: " + currentProperty);
					}
				}
			}
		}
开发者ID:khaliyo,项目名称:Spring.net-NHibernate.net-Asp.net-MVC-DWZ-,代码行数:95,代码来源:PathExpressionParser.cs

示例13: AppendToken

		protected virtual void AppendToken(QueryTranslator q, SqlString token)
		{
			if (expectingIndex > 0)
			{
				pathExpressionParser.SetLastCollectionElementIndexValue(token);
			}
			else
			{
				q.AppendWhereToken(token);
			}
		}
开发者ID:nikson,项目名称:nhibernate-core,代码行数:11,代码来源:WhereParser.cs

示例14: End

		/// <summary>
		/// 
		/// </summary>
		/// <param name="q"></param>
		public virtual void End(QueryTranslator q)
		{
			ignoreInitialJoin = false;

			IType propertyType = PropertyType;
			if (propertyType != null && propertyType.IsCollectionType)
			{
				collectionRole = ((CollectionType) propertyType).Role;
				collectionName = q.CreateNameForCollection(collectionRole);
				PrepareForIndex(q);
			}
			else
			{
				columns = CurrentColumns();
				SetType(q);
			}

			//important!!
			continuation = false;
		}
开发者ID:khaliyo,项目名称:Spring.net-NHibernate.net-Asp.net-MVC-DWZ-,代码行数:24,代码来源:PathExpressionParser.cs

示例15: AddFromCollection

		/// <summary>
		/// 
		/// </summary>
		/// <param name="q"></param>
		/// <returns></returns>
		public string AddFromCollection(QueryTranslator q)
		{
			IType collectionElementType = PropertyType;

			if (collectionElementType == null)
			{
				throw new QueryException(
					string.Format("must specify 'elements' for collection valued property in from clause: {0}", path));
			}
			if (collectionElementType.IsEntityType)
			{
				// an association
				IQueryableCollection collectionPersister = q.GetCollectionPersister(collectionRole);
				IQueryable entityPersister = (IQueryable) collectionPersister.ElementPersister;
				string clazz = entityPersister.EntityName;

				string elementName;
				if (collectionPersister.IsOneToMany)
				{
					elementName = collectionName;
					// allow index() function
					q.DecoratePropertyMapping(elementName, collectionPersister);
				}
				else
				{
					// many to many
					q.AddCollection(collectionName, collectionRole);
					elementName = q.CreateNameFor(clazz);
					AddJoin(elementName, (IAssociationType) collectionElementType);
				}
				q.AddFrom(elementName, clazz, joinSequence);
				currentPropertyMapping = new CollectionPropertyMapping(collectionPersister);
				return elementName;
			}
			
			// collection of values
			q.AddFromCollection(collectionName, collectionRole, joinSequence);
			return collectionName;
		}
开发者ID:khaliyo,项目名称:Spring.net-NHibernate.net-Asp.net-MVC-DWZ-,代码行数:44,代码来源:PathExpressionParser.cs


注:本文中的NHibernate.Hql.Classic.QueryTranslator类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。