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


C# QueryTranslator.CreateNameFor方法代码示例

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


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

示例1: ContinueFromManyToMany

		public string ContinueFromManyToMany(string 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:khaliyo,项目名称:Spring.net-NHibernate.net-Asp.net-MVC-DWZ-,代码行数:11,代码来源:PathExpressionParser.cs

示例2: 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

示例3: 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

示例4: Token


//.........这里部分代码省略.........
					afterAs = false;
					expectingJoin = true;
					expectingAs = false;
					entityName = null;
				}
				else if (afterIn)
				{
					// process the "old" HQL style where aliases appear _first
					// ie using the IN or IN CLASS constructions

					if (alias == null)
						throw new QueryException("alias not specified for: " + token);

					if (joinType != JoinType.None)
						throw new QueryException("outer or full join must be followed by path expressions");

					if (afterClass)
					{
						// treat it as a classname
						IQueryable p = q.GetPersisterUsingImports(token);
						if (p == null)
						{
							throw new QueryException("persister not found: " + token);
						}
						q.AddFromClass(alias, p);
					}
					else
					{
						// treat it as a path expression
						peParser.JoinType = JoinType.InnerJoin;
						peParser.UseThetaStyleJoin = true;
						ParserHelper.Parse(peParser, q.Unalias(token), ParserHelper.PathSeparators, q);
						if (!peParser.IsCollectionValued)
						{
							throw new QueryException("pathe expression did not resolve to collection: " + token);
						}
						string nm = peParser.AddFromCollection(q);
						q.SetAliasName(alias, nm);
					}

					alias = null;
					afterIn = false;
					afterClass = false;
					expectingJoin = true;
				}
				else
				{
					// handle a path expression or class name that appears
					// at the start, in the "new" HQL style or an alias that
					// appears at the start in the "old HQL stype
					IQueryable p = q.GetPersisterUsingImports(token);
					if (p != null)
					{
						// starts with the name of a mapped class (new style)
						if (joinType != JoinType.None)
							throw new QueryException("outer or full join must be followed by path expression");

						entityName = q.CreateNameFor(p.EntityName);
						q.AddFromClass(entityName, p);
						expectingAs = true;
					}
					else if (token.IndexOf('.') < 0)
					{
						// starts with an alias (old style)
						// semi-bad thing about this: can't re-alias another alias...
						alias = token;
						expectingIn = true;
					}
					else
					{
						// starts with a path expression (new style)

						// force HQL style: from Person p inner join p.cars c
						//if (joinType==JoinType.None) throw new QueryException("path expression must be preceded by full, left, right or inner join");

						//allow ODMG OQL style: from Person p, p.cars c
						if (joinType != JoinType.None)
							peParser.JoinType = joinType;
						else
							peParser.JoinType = JoinType.InnerJoin;

						peParser.UseThetaStyleJoin = q.IsSubquery;

						ParserHelper.Parse(peParser, q.Unalias(token), ParserHelper.PathSeparators, q);
						entityName = peParser.AddFromAssociation(q);

						joinType = JoinType.None;
						peParser.JoinType = JoinType.InnerJoin;

						if (afterFetch)
						{
							peParser.Fetch(q, entityName);
							afterFetch = false;
						}

						expectingAs = true;
					}
				}
			}
		}
开发者ID:hazzik,项目名称:nh-contrib-everything,代码行数:101,代码来源:FromParser.cs


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