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


C# ISessionFactoryImplementor.GetEntityPersister方法代码示例

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


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

示例1: IsEqual

		public override bool IsEqual(object x, object y, EntityMode entityMode, ISessionFactoryImplementor factory)
		{
			IEntityPersister persister = factory.GetEntityPersister(associatedEntityName);
			if (!persister.CanExtractIdOutOfEntity)
			{
				return base.IsEqual(x, y, entityMode);
			}

			object xid;
			
			if (x.IsProxy())
			{
				INHibernateProxy proxy = x as INHibernateProxy; 
				xid = proxy.HibernateLazyInitializer.Identifier;
			}
			else
			{
				xid = persister.GetIdentifier(x, entityMode);
			}

			object yid;
			
			if (y.IsProxy())
			{
				INHibernateProxy proxy = y as INHibernateProxy; 
				yid = proxy.HibernateLazyInitializer.Identifier;
			}
			else
			{
				yid = persister.GetIdentifier(y, entityMode);
			}

			return persister.IdentifierType.IsEqual(xid, yid, entityMode, factory);
		}
开发者ID:KaraokeStu,项目名称:nhibernate-core,代码行数:34,代码来源:EntityType.cs

示例2: GetQueryableCollection

		protected IQueryableCollection GetQueryableCollection(string entityName, string actualPropertyName,
		                                                      ISessionFactoryImplementor factory)
		{
			IPropertyMapping ownerMapping = (IPropertyMapping) factory.GetEntityPersister(entityName);
			IType type = ownerMapping.ToType(actualPropertyName);
			if (!type.IsCollectionType)
			{
				throw new MappingException(
					"Property path [" + entityName + "." + actualPropertyName + "] does not reference a collection"
					);
			}

			string role = ((CollectionType) type).Role;
			try
			{
				return (IQueryableCollection) factory.GetCollectionPersister(role);
			}
			catch (InvalidCastException cce)
			{
				throw new QueryException("collection role is not queryable: " + role, cce);
			}
			catch (Exception e)
			{
				throw new QueryException("collection role not found: " + role, e);
			}
		}
开发者ID:jaundice,项目名称:nhibernate-core,代码行数:26,代码来源:AbstractEmptinessExpression.cs

示例3: FindQueryableUsingImports

		public static IQueryable FindQueryableUsingImports(ISessionFactoryImplementor sfi, string className)
		{
			string importedClassName = sfi.GetImportedClassName(className);

			if (importedClassName == null)
			{
				return null;
			}

			return (IQueryable) sfi.GetEntityPersister(importedClassName, false);
		}
开发者ID:Novthirteen,项目名称:sconit_timesseiko,代码行数:11,代码来源:SessionFactoryHelper.cs

示例4: Destructure

		public object Destructure(object item, ISessionFactoryImplementor factory)
		{
			IDictionary map = (IDictionary)item;
			bool lazyPropertiesUnfetched = ((bool)map["_lazyPropertiesUnfetched"]);
			string subclass = (string)map["_subclass"];
			object version = map["_version"];
			IEntityPersister subclassPersister = factory.GetEntityPersister(subclass);
			string[] names = subclassPersister.PropertyNames;
			object[] state = new object[names.Length];
			for (int i = 0; i < names.Length; i++)
			{
				state[i] = map[names[i]];
			}
			return new CacheEntry(state, subclass, lazyPropertiesUnfetched, version);
		}
开发者ID:hazzik,项目名称:nh-contrib-everything,代码行数:15,代码来源:StructuredCacheEntry.cs

示例5: GetHashCode

		public override int GetHashCode(object x, ISessionFactoryImplementor factory)
		{
			IEntityPersister persister = factory.GetEntityPersister(associatedClass);
			if (!persister.HasIdentifierPropertyOrEmbeddedCompositeIdentifier)
			{
				return base.GetHashCode(x, factory);
			}

			object id;
			if (x is INHibernateProxy)
			{
				id = NHibernateProxyHelper.GetLazyInitializer((INHibernateProxy) x).Identifier;
			}
			else
			{
				id = persister.GetIdentifier(x);
			}
			return persister.IdentifierType.GetHashCode(id, factory);
		}
开发者ID:Novthirteen,项目名称:sconit_timesseiko,代码行数:19,代码来源:EntityType.cs

示例6: GetSemiResolvedType

		public override IType GetSemiResolvedType(ISessionFactoryImplementor factory)
		{
			return factory.GetEntityPersister(associatedEntityName).IdentifierType;
		}
开发者ID:KaraokeStu,项目名称:nhibernate-core,代码行数:4,代码来源:EntityType.cs

示例7: GetHashCode

		public override int GetHashCode(object x, EntityMode entityMode, ISessionFactoryImplementor factory)
		{
			IEntityPersister persister = factory.GetEntityPersister(associatedEntityName);
			if (!persister.CanExtractIdOutOfEntity)
			{
				return base.GetHashCode(x, entityMode);
			}

			object id;
			
			if (x.IsProxy())
			{
				INHibernateProxy proxy = x as INHibernateProxy; 
				id = proxy.HibernateLazyInitializer.Identifier;
			}
			else
			{
				id = persister.GetIdentifier(x, entityMode);
			}
			return persister.IdentifierType.GetHashCode(id, entityMode, factory);
		}
开发者ID:KaraokeStu,项目名称:nhibernate-core,代码行数:21,代码来源:EntityType.cs

示例8: GetAssociatedJoinable

		/// <summary> Retrieves the {@link Joinable} defining the associated entity. </summary>
		/// <param name="factory">The session factory. </param>
		/// <returns> The associated joinable </returns>
		public IJoinable GetAssociatedJoinable(ISessionFactoryImplementor factory)
		{
			return (IJoinable)factory.GetEntityPersister(associatedEntityName);
		}
开发者ID:KaraokeStu,项目名称:nhibernate-core,代码行数:7,代码来源:EntityType.cs

示例9: ToLoggableString

		public override string ToLoggableString(object value, ISessionFactoryImplementor factory)
		{
			if (value == null)
			{
				return "null";
			}

			IEntityPersister persister = factory.GetEntityPersister(associatedEntityName);
			StringBuilder result = new StringBuilder().Append(associatedEntityName);

			if (persister.HasIdentifierProperty)
			{
				EntityMode? entityMode = persister.GuessEntityMode(value);
				object id;
				if (!entityMode.HasValue)
				{
					if (isEmbeddedInXML)
						throw new InvalidCastException(value.GetType().FullName);

					id = value;
				}
				else
				{
					id = GetIdentifier(value, persister, entityMode.Value);
				}

				result.Append('#').Append(persister.IdentifierType.ToLoggableString(id, factory));
			}

			return result.ToString();
		}
开发者ID:KaraokeStu,项目名称:nhibernate-core,代码行数:31,代码来源:EntityType.cs

示例10: GetEntityPersister

		protected virtual IEntityPersister GetEntityPersister(ISessionFactoryImplementor factory, string entityName)
		{
			// Check for an exact match.
			IEntityPersister persister = factory.TryGetEntityPersister(entityName);
			if (persister != null)
			{
				return persister;
			}

			// Couldn't find persister through exact name, try finding a single implementing class.
			string[] implementors = factory.GetImplementors(entityName);
			if (implementors.Length > 1)
			{
				var messageBuilder = new StringBuilder(512);
				messageBuilder.AppendLine(string.Format("Ambiguous persister for {0} implemented by more than one hierarchy: ",
				                                        entityName));
				Array.ForEach(implementors, s=> messageBuilder.AppendLine(s));

				throw new HibernateException(messageBuilder.ToString());
			}
			if (implementors.Length == 0)
			{
				return null;
			}
			return factory.GetEntityPersister(implementors[0]);
		}
开发者ID:Mrding,项目名称:Ribbon,代码行数:26,代码来源:DefaultLoadEventListener.cs

示例11: CustomLoader

        public CustomLoader(
            ICustomQuery customQuery,
            ISessionFactoryImplementor factory)
            : base(factory)
        {
            this.sql = customQuery.SQL;
            this.querySpaces.AddAll(customQuery.QuerySpaces);
            this.namedParameterBindPoints = customQuery.NamedParameterBindPoints;

            IList entityPersisters = new ArrayList();
            IList entityOwners = new ArrayList();
            IList entityAliases = new ArrayList();

            IList collectionPersisters = new ArrayList();
            IList collectionOwners = new ArrayList();
            IList collectionAliases = new ArrayList();

            IList lockModes = new ArrayList();
            IList resultColumnProcessors = new ArrayList();
            IList nonScalarReturnList = new ArrayList();
            IList resultTypes = new ArrayList();
            IList specifiedAliases = new ArrayList();

            int returnableCounter = 0;
            bool hasScalars = false;

            foreach (IReturn rtn in customQuery.CustomQueryReturns)
            {
                if (rtn is ScalarReturn)
                {
                    ScalarReturn scalarRtn = (ScalarReturn) rtn;
                    resultTypes.Add(scalarRtn.Type);
                    specifiedAliases.Add(scalarRtn.ColumnAlias);
                    resultColumnProcessors.Add(
                        new ScalarResultColumnProcessor(
                            scalarRtn.ColumnAlias,
                            scalarRtn.Type
                            )
                        );
                    hasScalars = true;
                }
                else if (rtn is RootReturn)
                {
                    RootReturn rootRtn = (RootReturn) rtn;
                    IQueryable persister = (IQueryable) factory.GetEntityPersister(rootRtn.EntityName);
                    entityPersisters.Add(persister);
                    lockModes.Add(rootRtn.LockMode);
                    resultColumnProcessors.Add(new NonScalarResultColumnProcessor(returnableCounter++));
                    nonScalarReturnList.Add(rtn);
                    entityOwners.Add(-1);
                    resultTypes.Add(persister.Type);
                    specifiedAliases.Add(rootRtn.Alias);
                    entityAliases.Add(rootRtn.EntityAliases);
                    querySpaces.AddAll(persister.QuerySpaces);
                }
                else if (rtn is CollectionReturn)
                {
                    CollectionReturn collRtn = (CollectionReturn) rtn;
                    String role = collRtn.OwnerEntityName + "." + collRtn.OwnerProperty;
                    IQueryableCollection persister = (IQueryableCollection) factory.GetCollectionPersister(role);
                    collectionPersisters.Add(persister);
                    lockModes.Add(collRtn.LockMode);
                    resultColumnProcessors.Add(new NonScalarResultColumnProcessor(returnableCounter++));
                    nonScalarReturnList.Add(rtn);
                    collectionOwners.Add(-1);
                    resultTypes.Add(persister.Type);
                    specifiedAliases.Add(collRtn.Alias);
                    collectionAliases.Add(collRtn.CollectionAliases);
                    // determine if the collection elements are entities...
                    IType elementType = persister.ElementType;
                    if (elementType.IsEntityType)
                    {
                        IQueryable elementPersister = (IQueryable) ((EntityType) elementType).GetAssociatedJoinable(factory);
                        entityPersisters.Add(elementPersister);
                        entityOwners.Add(-1);
                        entityAliases.Add(collRtn.ElementEntityAliases);
                        querySpaces.AddAll(elementPersister.QuerySpaces);
                    }
                }
                else if (rtn is EntityFetchReturn)
                {
                    EntityFetchReturn fetchRtn = (EntityFetchReturn) rtn;
                    NonScalarReturn ownerDescriptor = fetchRtn.Owner;
                    int ownerIndex = nonScalarReturnList.IndexOf(ownerDescriptor);
                    entityOwners.Add(ownerIndex);
                    lockModes.Add(fetchRtn.LockMode);
                    IQueryable ownerPersister = DetermineAppropriateOwnerPersister(ownerDescriptor);
                    EntityType fetchedType = (EntityType) ownerPersister.GetPropertyType(fetchRtn.OwnerProperty);
                    string entityName = fetchedType.GetAssociatedEntityName(Factory);
                    IQueryable persister = (IQueryable) factory.GetEntityPersister(entityName);
                    entityPersisters.Add(persister);
                    nonScalarReturnList.Add(rtn);
                    specifiedAliases.Add(fetchRtn.Alias);
                    entityAliases.Add(fetchRtn.EntityAliases);
                    querySpaces.AddAll(persister.QuerySpaces);
                }
                else if (rtn is CollectionFetchReturn)
                {
                    CollectionFetchReturn fetchRtn = (CollectionFetchReturn) rtn;
                    NonScalarReturn ownerDescriptor = fetchRtn.Owner;
//.........这里部分代码省略.........
开发者ID:zibler,项目名称:zibler,代码行数:101,代码来源:CustomLoader.cs

示例12: CustomLoader

		public CustomLoader(ICustomQuery customQuery, ISessionFactoryImplementor factory) : base(factory)
		{
			sql = customQuery.SQL;
			querySpaces.AddAll(customQuery.QuerySpaces);
			namedParameterBindPoints = customQuery.NamedParameterBindPoints;

			List<IQueryable> entitypersisters = new List<IQueryable>();
			List<int> entityowners = new List<int>();
			List<IEntityAliases> entityaliases = new List<IEntityAliases>();

			List<IQueryableCollection> collectionpersisters = new List<IQueryableCollection>();
			List<int> collectionowners = new List<int>();
			List<ICollectionAliases> collectionaliases = new List<ICollectionAliases>();

			List<LockMode> lockmodes = new List<LockMode>();
			List<IResultColumnProcessor> resultColumnProcessors = new List<IResultColumnProcessor>();
			List<IReturn> nonScalarReturnList = new List<IReturn>();
			List<IType> resulttypes = new List<IType>();
			List<string> specifiedAliases = new List<string>();

			int returnableCounter = 0;
			bool hasScalars = false;

			foreach (IReturn rtn in customQuery.CustomQueryReturns)
			{
				if (rtn is ScalarReturn)
				{
					ScalarReturn scalarRtn = (ScalarReturn) rtn;
					resulttypes.Add(scalarRtn.Type);
					specifiedAliases.Add(scalarRtn.ColumnAlias);
					resultColumnProcessors.Add(new ScalarResultColumnProcessor(scalarRtn.ColumnAlias, scalarRtn.Type));
					hasScalars = true;
				}
				else if (rtn is RootReturn)
				{
					RootReturn rootRtn = (RootReturn) rtn;
					IQueryable persister = (IQueryable) factory.GetEntityPersister(rootRtn.EntityName);
					entitypersisters.Add(persister);
					lockmodes.Add(rootRtn.LockMode);
					resultColumnProcessors.Add(new NonScalarResultColumnProcessor(returnableCounter++));
					nonScalarReturnList.Add(rtn);
					entityowners.Add(-1);
					resulttypes.Add(persister.Type);
					specifiedAliases.Add(rootRtn.Alias);
					entityaliases.Add(rootRtn.EntityAliases);
					querySpaces.AddAll(persister.QuerySpaces);
				}
				else if (rtn is CollectionReturn)
				{
					CollectionReturn collRtn = (CollectionReturn) rtn;
					string role = collRtn.OwnerEntityName + "." + collRtn.OwnerProperty;
					IQueryableCollection persister = (IQueryableCollection) factory.GetCollectionPersister(role);
					collectionpersisters.Add(persister);
					lockmodes.Add(collRtn.LockMode);
					resultColumnProcessors.Add(new NonScalarResultColumnProcessor(returnableCounter++));
					nonScalarReturnList.Add(rtn);
					collectionowners.Add(-1);
					resulttypes.Add(persister.Type);
					specifiedAliases.Add(collRtn.Alias);
					collectionaliases.Add(collRtn.CollectionAliases);
					// determine if the collection elements are entities...
					IType elementType = persister.ElementType;
					if (elementType.IsEntityType)
					{
						IQueryable elementPersister = (IQueryable) ((EntityType) elementType).GetAssociatedJoinable(factory);
						entitypersisters.Add(elementPersister);
						entityowners.Add(-1);
						entityaliases.Add(collRtn.ElementEntityAliases);
						querySpaces.AddAll(elementPersister.QuerySpaces);
					}
				}
				else if (rtn is EntityFetchReturn)
				{
					EntityFetchReturn fetchRtn = (EntityFetchReturn) rtn;
					NonScalarReturn ownerDescriptor = fetchRtn.Owner;
					int ownerIndex = nonScalarReturnList.IndexOf(ownerDescriptor);
					entityowners.Add(ownerIndex);
					lockmodes.Add(fetchRtn.LockMode);
					IQueryable ownerPersister = DetermineAppropriateOwnerPersister(ownerDescriptor);
					EntityType fetchedType = (EntityType) ownerPersister.GetPropertyType(fetchRtn.OwnerProperty);
					string entityName = fetchedType.GetAssociatedEntityName(Factory);
					IQueryable persister = (IQueryable) factory.GetEntityPersister(entityName);
					entitypersisters.Add(persister);
					nonScalarReturnList.Add(rtn);
					specifiedAliases.Add(fetchRtn.Alias);
					entityaliases.Add(fetchRtn.EntityAliases);
					querySpaces.AddAll(persister.QuerySpaces);
				}
				else if (rtn is CollectionFetchReturn)
				{
					CollectionFetchReturn fetchRtn = (CollectionFetchReturn) rtn;
					NonScalarReturn ownerDescriptor = fetchRtn.Owner;
					int ownerIndex = nonScalarReturnList.IndexOf(ownerDescriptor);
					collectionowners.Add(ownerIndex);
					lockmodes.Add(fetchRtn.LockMode);
					IQueryable ownerPersister = DetermineAppropriateOwnerPersister(ownerDescriptor);
					string role = ownerPersister.EntityName + '.' + fetchRtn.OwnerProperty;
					IQueryableCollection persister = (IQueryableCollection) factory.GetCollectionPersister(role);
					collectionpersisters.Add(persister);
					nonScalarReturnList.Add(rtn);
//.........这里部分代码省略.........
开发者ID:hazzik,项目名称:nh-contrib-everything,代码行数:101,代码来源:CustomLoader.cs

示例13: AbstractCollectionPersister

		public AbstractCollectionPersister(Mapping.Collection collection, ICacheConcurrencyStrategy cache,
		                                   ISessionFactoryImplementor factory)
		{
			this.factory = factory;
			dialect = factory.Dialect;
			this.cache = cache;
			//sqlExceptionConverter = factory.SQLExceptionConverter;
			collectionType = collection.CollectionType;
			role = collection.Role;
			ownerClass = collection.OwnerClass;
			ownerPersister = factory.GetEntityPersister(ownerClass);
			queryLoaderName = collection.LoaderName;
			Alias alias = new Alias("__");

			sqlOrderByString = collection.OrderBy;
			hasOrder = sqlOrderByString != null;
			sqlOrderByStringTemplate = hasOrder
			                           	? Template.RenderOrderByStringTemplate(sqlOrderByString, dialect,
			                           	                                       factory.SQLFunctionRegistry) : null;

			sqlWhereString = collection.Where;
			hasWhere = sqlWhereString != null;
			sqlWhereStringTemplate = hasWhere
			                         	? Template.RenderWhereStringTemplate(sqlWhereString, dialect, factory.SQLFunctionRegistry)
			                         	: null;

			hasOrphanDelete = collection.OrphanDelete;

			batchSize = collection.BatchSize;
			isVersioned = collection.IsOptimisticLocked;

			keyType = collection.Key.Type;
			int keySpan = collection.Key.ColumnSpan;
			keyColumnNames = new string[keySpan];
			string[] keyAliases = new string[keySpan];
			int k = 0;
			foreach (Column col in collection.Key.ColumnCollection)
			{
				keyColumnNames[k] = col.GetQuotedName(dialect);
				keyAliases[k] = col.GetAlias(dialect);
				k++;
			}
			keyColumnAliases = alias.ToAliasStrings(keyAliases, dialect);
			//unquotedKeyColumnNames = StringHelper.Unquote( keyColumnAliases );
			ISet distinctColumns = new HashedSet();
			CheckColumnDuplication(distinctColumns, collection.Key.ColumnCollection);

			//isSet = collection.IsSet;
			//isSorted = collection.IsSorted;
			primitiveArray = collection.IsPrimitiveArray;
			array = collection.IsArray;
			subselectLoadable = collection.IsSubselectLoadable;

			IValue element = collection.Element;
			int elementSpan = element.ColumnSpan;
			Table table = collection.CollectionTable;
			fetchMode = element.FetchMode;
			elementType = element.Type;

			if (!collection.IsOneToMany)
			{
				CheckColumnDuplication(distinctColumns, element.ColumnCollection);
			}

			if (elementType.IsEntityType)
			{
				elementPersister = factory.GetEntityPersister(((EntityType) elementType).AssociatedClass);
			}
			else
			{
				elementPersister = null;
			}

			qualifiedTableName = table.GetQualifiedName(dialect, factory.DefaultSchema);
			elementColumnAliases = new string[elementSpan];
			elementColumnNames = new string[elementSpan];
			elementFormulaTemplates = new string[elementSpan];
			elementFormulas = new string[elementSpan];
			elementColumnIsSettable = new bool[elementSpan];
			elementColumnIsInPrimaryKey = new bool[elementSpan];
			int j = 0;
			foreach (ISelectable selectable in element.ColumnCollection)
			{
				elementColumnAliases[j] = selectable.GetAlias(dialect);
				if (selectable.IsFormula)
				{
					Formula form = (Formula) selectable;
					elementFormulaTemplates[j] = form.GetTemplate(dialect, factory.SQLFunctionRegistry);
					elementFormulas[j] = form.FormulaString;
				}
				else
				{
					Column col = (Column) selectable;
					elementColumnNames[j] = col.GetQuotedName(dialect);
					elementColumnIsSettable[j] = true;
					elementColumnIsInPrimaryKey[j] = !col.IsNullable;
				}
				j++;
			}

//.........这里部分代码省略.........
开发者ID:Novthirteen,项目名称:sconit_timesseiko,代码行数:101,代码来源:AbstractCollectionPersister.cs

示例14: ToLoggableString

		public override string ToLoggableString(object value, ISessionFactoryImplementor factory)
		{
			IEntityPersister persister = factory.GetEntityPersister(associatedClass);
			if (value == null)
			{
				return "null";
			}
			StringBuilder result = new StringBuilder();
			result.Append(StringHelper.Unqualify(NHibernateProxyHelper.GetClass(value).FullName));
			if (persister.HasIdentifierProperty)
			{
				result.Append('#')
					.Append(persister.IdentifierType.ToLoggableString(NHibernateProxyHelper.GetIdentifier(value, persister), factory));
			}

			return result.ToString();
		}
开发者ID:Novthirteen,项目名称:sconit_timesseiko,代码行数:17,代码来源:EntityType.cs

示例15: GetSubclassEntityPersister

        public IEntityPersister GetSubclassEntityPersister(object instance, ISessionFactoryImplementor factory,
																											EntityMode entityMode)
        {
            if (!HasSubclasses)
            {
                return this;
            }
            else
            {
                // TODO : really need a way to do something like :
                //      getTuplizer(entityMode).determineConcreteSubclassEntityName(instance)
                System.Type clazz = instance.GetType();
                if (clazz == GetMappedClass(entityMode))
                {
                    return this;
                }
                else
                {
                    string subclassEntityName = GetSubclassEntityName(clazz);
                    if (subclassEntityName == null)
                    {
                        throw new HibernateException("instance not of expected entity type: " + clazz.FullName + " is not a: "
                                                                                 + EntityName);
                    }
                    else
                    {
                        return factory.GetEntityPersister(subclassEntityName);
                    }
                }
            }
        }
开发者ID:aistrate,项目名称:TypingPracticeTexts,代码行数:31,代码来源:AbstractEntityPersister.cs


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