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


C# IPersistentCollection.NeedsInserting方法代码示例

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


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

示例1: InsertRows

		public void InsertRows(IPersistentCollection collection, object id, ISessionImplementor session)
		{
			if (!isInverse && RowInsertEnabled)
			{
				if (log.IsDebugEnabled)
				{
					log.Debug("Inserting rows of collection: " + MessageHelper.InfoString(this, id, Factory));
				}

				try
				{
					// insert all the new entries
					collection.PreInsert(this);
					IExpectation expectation = Expectations.AppropriateExpectation(insertCheckStyle);
					//bool callable = InsertCallable;
					bool useBatch = expectation.CanBeBatched;
					int i = 0;
					int count = 0;

					IEnumerable entries = collection.Entries(this);
					foreach (object entry in entries)
					{
						if (collection.NeedsInserting(entry, i, elementType))
						{
							object entryId;
							if (!IsIdentifierAssignedByInsert)
							{
								// NH Different implementation: write once
								entryId = PerformInsert(id, collection, expectation, entry, i, useBatch, false, session);
							}
							else
							{
								entryId = PerformInsert(id, collection, entry, i, session);
							}
							collection.AfterRowInsert(this, entry, i, entryId);
							count++;
						}
						i++;
					}

					if (log.IsDebugEnabled)
					{
						log.Debug(string.Format("done inserting rows: {0} inserted", count));
					}
				}
				catch (DbException sqle)
				{
					throw ADOExceptionHelper.Convert(sqlExceptionConverter, sqle,
					                                 "could not insert collection rows: " + MessageHelper.InfoString(this, id));
				}
			}
		}
开发者ID:khaliyo,项目名称:Spring.net-NHibernate.net-Asp.net-MVC-DWZ-,代码行数:52,代码来源:AbstractCollectionPersister.cs

示例2: InsertRows

		public void InsertRows(IPersistentCollection collection, object id, ISessionImplementor session)
		{
			if (!isInverse)
			{
				if (log.IsDebugEnabled)
				{
					log.Debug("Inserting rows of collection: " + role + "#" + id);
				}

				try
				{
					// insert all the new entries
					collection.PreInsert(this);
					IExpectation expectation = Expectations.AppropriateExpectation(insertCheckStyle);
					bool useBatch = expectation.CanBeBatched;
					int i = 0;
					int count = 0;
					int offset = 0;

					IEnumerable entries = collection.Entries();
					foreach (object entry in entries)
					{
						if (collection.NeedsInserting(entry, i, elementType))
						{
							IDbCommand st = useBatch
							                	? session.Batcher.PrepareBatchCommand(
							                	  	SqlInsertRowString.CommandType,
							                	  	SqlInsertRowString.Text,
							                	  	SqlInsertRowString.ParameterTypes)
							                	: session.Batcher.PrepareCommand(
							                	  	SqlInsertRowString.CommandType,
							                	  	SqlInsertRowString.Text,
							                	  	SqlInsertRowString.ParameterTypes);
							try
							{
								//offset += expectation.Prepare(st, factory.ConnectionProvider.Driver);
								int loc = WriteKey(st, id, offset, session);
								if (hasIdentifier)
								{
									loc = WriteIdentifier(st, collection.GetIdentifier(entry, i), loc, session);
								}
								if (hasIndex /*&& !indexIsFormula*/)
								{
									loc = WriteIndex(st, collection.GetIndex(entry, i), loc, session);
								}
								loc = WriteElement(st, collection.GetElement(entry), loc, session);
								if (useBatch)
								{
									session.Batcher.AddToBatch(expectation);
								}
								else
								{
									expectation.VerifyOutcomeNonBatched(session.Batcher.ExecuteNonQuery(st), st);
								}
								collection.AfterRowInsert(this, entry, i);
								count++;
							}
							catch (Exception e)
							{
								if (useBatch)
								{
									session.Batcher.AbortBatch(e);
								}
								throw;
							}
							finally
							{
								if (!useBatch)
								{
									session.Batcher.CloseCommand(st, null);
								}
							}
						}
						i++;
					}

					if (log.IsDebugEnabled)
					{
						log.Debug(string.Format("done inserting rows: {0} inserted", count));
					}
				}
				catch (HibernateException)
				{
					// Do not call Convert on HibernateExceptions
					throw;
				}
				catch (Exception sqle)
				{
					throw Convert(sqle, "could not insert collection rows: " + MessageHelper.InfoString(this, id));
				}
			}
		}
开发者ID:Novthirteen,项目名称:sconit_timesseiko,代码行数:92,代码来源:AbstractCollectionPersister.cs


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