本文整理匯總了C#中NHibernate.Hql.Classic.QueryTranslator.AddFrom方法的典型用法代碼示例。如果您正苦於以下問題:C# QueryTranslator.AddFrom方法的具體用法?C# QueryTranslator.AddFrom怎麽用?C# QueryTranslator.AddFrom使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類NHibernate.Hql.Classic.QueryTranslator
的用法示例。
在下文中一共展示了QueryTranslator.AddFrom方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的C#代碼示例。
示例1: 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;
}
示例2: AddFromAssociation
/// <summary>
///
/// </summary>
/// <param name="q"></param>
/// <returns></returns>
public string AddFromAssociation(QueryTranslator q)
{
if (IsCollectionValued)
{
return AddFromCollection(q);
}
q.AddFrom(currentName, joinSequence);
return currentName;
}