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


C# IPersistentCollection.GetDeletes方法代码示例

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


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

示例1: DeleteRows

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

				bool deleteByIndex = !IsOneToMany && hasIndex && !indexContainsFormula;

				try
				{
					// delete all the deleted entries
					IEnumerator deletes = collection.GetDeletes(this, !deleteByIndex).GetEnumerator();
					if (deletes.MoveNext())
					{
						deletes.Reset();
						int offset = 0;
						int count = 0;

						while (deletes.MoveNext())
						{
							IDbCommand st;
							IExpectation expectation = Expectations.AppropriateExpectation(deleteCheckStyle);
							//bool callable = DeleteCallable;

							bool useBatch = expectation.CanBeBatched;
							if (useBatch)
							{
								st =
									session.Batcher.PrepareBatchCommand(SqlDeleteRowString.CommandType, SqlDeleteRowString.Text,
									                                    SqlDeleteRowString.ParameterTypes);
							}
							else
							{
								st =
									session.Batcher.PrepareCommand(SqlDeleteRowString.CommandType, SqlDeleteRowString.Text,
									                               SqlDeleteRowString.ParameterTypes);
							}
							try
							{
								object entry = deletes.Current;
								int loc = offset;
								if (hasIdentifier)
								{
									WriteIdentifier(st, entry, loc, session);
								}
								else
								{
									loc = WriteKey(st, id, loc, session);

									if (deleteByIndex)
									{
										WriteIndexToWhere(st, entry, loc, session);
									}
									else
									{
										WriteElementToWhere(st, entry, loc, session);
									}
								}
								if (useBatch)
								{
									session.Batcher.AddToBatch(expectation);
								}
								else
								{
									expectation.VerifyOutcomeNonBatched(session.Batcher.ExecuteNonQuery(st), st);
								}
								count++;
							}
							catch (Exception e)
							{
								if (useBatch)
								{
									session.Batcher.AbortBatch(e);
								}
								throw;
							}
							finally
							{
								if (!useBatch)
								{
									session.Batcher.CloseCommand(st, null);
								}
							}
						}

						if (log.IsDebugEnabled)
						{
							log.Debug("done deleting collection rows: " + count + " deleted");
						}
					}
					else
					{
						if (log.IsDebugEnabled)
						{
							log.Debug("no rows to delete");
						}
					}
//.........这里部分代码省略.........
开发者ID:khaliyo,项目名称:Spring.net-NHibernate.net-Asp.net-MVC-DWZ-,代码行数:101,代码来源:AbstractCollectionPersister.cs

示例2: DeleteRows

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

				bool deleteByIndex = !IsOneToMany && hasIndex /* TODO H3: && !indexContainsFormula*/;

				try
				{
					// delete all the deleted entries
					ICollection deletes = collection.GetDeletes(elementType, !deleteByIndex);
					if (deletes.Count > 0)
					{
						int offset = 0;
						int count = 0;
						IExpectation expectation = Expectations.AppropriateExpectation(deleteCheckStyle);
						bool useBatch = expectation.CanBeBatched;
						IDbCommand st = null;

						try
						{
							foreach (object entry in deletes)
							{
								if (useBatch)
								{
									if (st != null)
									{
										st = session.Batcher.PrepareBatchCommand(
											SqlDeleteRowString.CommandType,
											SqlDeleteRowString.Text,
											SqlDeleteRowString.ParameterTypes);
									}
								}
								else
								{
									st = session.Batcher.PrepareCommand(
										SqlDeleteRowString.CommandType,
										SqlDeleteRowString.Text,
										SqlDeleteRowString.ParameterTypes);
								}
								//offset += expectation.Prepare(st, factory.ConnectionProvider.Driver);
								int loc = offset;
								if (hasIdentifier)
								{
									WriteIdentifier(st, entry, loc, session);
								}
								else
								{
									loc = WriteKey(st, id, loc, session);

									if (deleteByIndex)
									{
										WriteIndexToWhere(st, entry, loc, session);
									}
									else
									{
										WriteElementToWhere(st, entry, loc, session);
									}
								}
								if (useBatch)
								{
									session.Batcher.AddToBatch(expectation);
								}
								else
								{
									expectation.VerifyOutcomeNonBatched(session.Batcher.ExecuteNonQuery(st), st);
								}
								count++;
							}
						}
						catch (Exception e)
						{
							if (useBatch)
							{
								session.Batcher.AbortBatch(e);
							}
							throw;
						}
						finally
						{
							if (!useBatch)
							{
								session.Batcher.CloseCommand(st, null);
							}
						}

						if (log.IsDebugEnabled)
						{
							log.Debug("done deleting collection rows: " + count + " deleted");
						}
					}
					else
					{
						if (log.IsDebugEnabled)
						{
							log.Debug("no rows to delete");
//.........这里部分代码省略.........
开发者ID:Novthirteen,项目名称:sconit_timesseiko,代码行数:101,代码来源:AbstractCollectionPersister.cs


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