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


C# IPersistentCollection.GetElement方法代码示例

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


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

示例1: PerformInsert

		protected object PerformInsert(object ownerId, IPersistentCollection collection, IExpectation expectation,
		                               object entry, int index, bool useBatch, bool callable, ISessionImplementor session)
		{
			object entryId = null;
			int offset = 0;
			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);
				offset = WriteKey(st, ownerId, offset, session);
				if (hasIdentifier)
				{
					entryId = collection.GetIdentifier(entry, index);
					offset = WriteIdentifier(st, entryId, offset, session);
				}
				if (hasIndex)
				{
					offset = WriteIndex(st, collection.GetIndex(entry, index, this), offset, session);
				}
				WriteElement(st, collection.GetElement(entry), offset, session);
				if (useBatch)
				{
					session.Batcher.AddToBatch(expectation);
				}
				else
				{
					expectation.VerifyOutcomeNonBatched(session.Batcher.ExecuteNonQuery(st), st);
				}
			}
			catch (Exception e)
			{
				if (useBatch)
				{
					session.Batcher.AbortBatch(e);
				}
				throw;
			}
			finally
			{
				if (!useBatch)
				{
					session.Batcher.CloseCommand(st, null);
				}
			}
			return entryId;
		}
开发者ID:khaliyo,项目名称:Spring.net-NHibernate.net-Asp.net-MVC-DWZ-,代码行数:50,代码来源:AbstractCollectionPersister.cs

示例2: DoUpdateRows


//.........这里部分代码省略.........
								{
									session.Batcher.AddToBatch(deleteExpectation);
								}
								else
								{
									deleteExpectation.VerifyOutcomeNonBatched(session.Batcher.ExecuteNonQuery(st), st);
								}
								count++;
							}
							i++;
						}
					}
					catch (Exception e)
					{
						if (useBatch)
						{
							session.Batcher.AbortBatch(e);
						}
						throw;
					}
					finally
					{
						if (!useBatch && st != null)
						{
							session.Batcher.CloseCommand(st, null);
						}
					}
				}

				if (RowInsertEnabled)
				{
					IExpectation insertExpectation = Expectations.AppropriateExpectation(InsertCheckStyle);
					//bool callable = InsertCallable;
					bool useBatch = insertExpectation.CanBeBatched;
					SqlCommandInfo sql = SqlInsertRowString;
					IDbCommand st = null;

					// now update all changed or added rows fks
					try
					{
						int i = 0;
						IEnumerable entries = collection.Entries(this);
						foreach (object entry in entries)
						{
							if (collection.NeedsUpdating(entry, i, ElementType))
							{
								if (useBatch)
								{
									st = session.Batcher.PrepareBatchCommand(SqlInsertRowString.CommandType, sql.Text,
																			 SqlInsertRowString.ParameterTypes);
								}
								else
								{
									st = session.Batcher.PrepareCommand(SqlInsertRowString.CommandType, sql.Text,
																		SqlInsertRowString.ParameterTypes);
								}

								//offset += insertExpectation.Prepare(st, Factory.ConnectionProvider.Driver);
								int loc = WriteKey(st, id, offset, session);
								if (HasIndex && !indexContainsFormula)
								{
									loc = WriteIndexToWhere(st, collection.GetIndex(entry, i, this), loc, session);
								}
								WriteElementToWhere(st, collection.GetElement(entry), loc, session);
								if (useBatch)
								{
									session.Batcher.AddToBatch(insertExpectation);
								}
								else
								{
									insertExpectation.VerifyOutcomeNonBatched(session.Batcher.ExecuteNonQuery(st), st);
								}
								count++;
							}
							i++;
						}
					}
					catch (Exception e)
					{
						if (useBatch)
						{
							session.Batcher.AbortBatch(e);
						}
						throw;
					}
					finally
					{
						if (!useBatch && st != null)
						{
							session.Batcher.CloseCommand(st, null);
						}
					}
				}
				return count;
			}
			catch (DbException sqle)
			{
				throw ADOExceptionHelper.Convert(SQLExceptionConverter, sqle, "could not update collection rows: " + MessageHelper.CollectionInfoString(this, collection, id, session));
			}
		}
开发者ID:mrhihi,项目名称:nhibernate-core,代码行数:101,代码来源:OneToManyPersister.cs

示例3: Recreate

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

				try
				{
					// create all the new entries
					IEnumerable entries = collection.Entries();
					IExpectation expectation = Expectations.AppropriateExpectation(insertCheckStyle);
					bool useBatch = expectation.CanBeBatched;

					int i = 0;
					int count = 0;
					collection.PreInsert(this);

					IDbCommand st = null;
					foreach (object entry in entries)
					{
						if (collection.EntryExists(entry, i))
						{
							try
							{
								int offset = 0;
								if (useBatch)
								{
									if (st == null)
									{
										st = session.Batcher.PrepareBatchCommand(
											SqlInsertRowString.CommandType,
											SqlInsertRowString.Text,
											SqlInsertRowString.ParameterTypes);
									}
								}
								else
								{
									st = session.Batcher.PrepareCommand(
										SqlInsertRowString.CommandType,
										SqlInsertRowString.Text,
										SqlInsertRowString.ParameterTypes);
								}
								//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 collection: {0} rows inserted", count));
					}

					if (count == 0 && log.IsDebugEnabled)
					{
						log.Debug("collection was empty");
					}
				}
				catch (HibernateException)
				{
					// Do not call Convert on HibernateExceptions
					throw;
//.........这里部分代码省略.........
开发者ID:Novthirteen,项目名称:sconit_timesseiko,代码行数:101,代码来源:AbstractCollectionPersister.cs

示例4: DoUpdateRows

		protected override int DoUpdateRows(object id, IPersistentCollection collection, ISessionImplementor session)
		{
			if (ArrayHelper.IsAllFalse(elementColumnIsSettable)) return 0;

			try
			{
				IDbCommand st = null;
				IExpectation expectation = Expectations.AppropriateExpectation(UpdateCheckStyle);
				//bool callable = UpdateCallable;
				bool useBatch = expectation.CanBeBatched;
				IEnumerable entries = collection.Entries(this);
				int i = 0;
				int count = 0;
				foreach (object entry in entries)
				{
					if (collection.NeedsUpdating(entry, i, ElementType))
					{
						int offset = 0;
						if (useBatch)
						{
							if (st == null)
							{
								st =
									session.Batcher.PrepareBatchCommand(SqlUpdateRowString.CommandType, SqlUpdateRowString.Text,
									                                    SqlUpdateRowString.ParameterTypes);
							}
						}
						else
						{
							st =
								session.Batcher.PrepareCommand(SqlUpdateRowString.CommandType, SqlUpdateRowString.Text,
								                               SqlUpdateRowString.ParameterTypes);
						}

						try
						{
							//offset += expectation.Prepare(st, Factory.ConnectionProvider.Driver);

							int loc = WriteElement(st, collection.GetElement(entry), offset, session);
							if (hasIdentifier)
							{
								WriteIdentifier(st, collection.GetIdentifier(entry, i), loc, session);
							}
							else
							{
								loc = WriteKey(st, id, loc, session);
								if (HasIndex && !indexContainsFormula)
								{
									WriteIndexToWhere(st, collection.GetIndex(entry, i, this), loc, session);
								}
								else
								{
									WriteElementToWhere(st, collection.GetSnapshotElement(entry, i), loc, session);
								}
							}

							if (useBatch)
							{
								session.Batcher.AddToBatch(expectation);
							}
							else
							{
								expectation.VerifyOutcomeNonBatched(session.Batcher.ExecuteNonQuery(st), st);
							}
						}
						catch (Exception e)
						{
							if (useBatch)
							{
								session.Batcher.AbortBatch(e);
							}
							throw;
						}
						finally
						{
							if (!useBatch)
							{
								session.Batcher.CloseCommand(st, null);
							}
						}
						count++;
					}
					i++;
				}
				return count;
			}
			catch (DbException sqle)
			{
				throw ADOExceptionHelper.Convert(SQLExceptionConverter, sqle,
				                                 "could not update collection rows: " + MessageHelper.InfoString(this, id),
				                                 SqlUpdateRowString.Text);
			}
		}
开发者ID:paulbatum,项目名称:nhibernate,代码行数:93,代码来源:BasicCollectionPersister.cs

示例5: Recreate

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

                try
                {
                    // create all the new entries
                    IEnumerator entries = collection.Entries(this).GetEnumerator();
                    if (entries.MoveNext())
                    {
                        entries.Reset();
                        collection.PreInsert(this);
                        int i = 0;
                        int count = 0;

                        while (entries.MoveNext())
                        {
                            object entry = entries.Current;
                            if (collection.EntryExists(entry, i))
                            {
                                int offset = 0;
                                IDbCommand st;
                                IExpectation expectation = Expectations.AppropriateExpectation(insertCheckStyle);
                                //bool callable = InsertCallable;

                                bool useBatch = expectation.CanBeBatched;
                                if (useBatch)
                                {
                                    st =
                                        session.Batcher.PrepareBatchCommand(SqlInsertRowString.CommandType, SqlInsertRowString.Text,
                                                                            SqlInsertRowString.ParameterTypes);
                                }
                                else
                                {
                                    st =
                                        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 && !isPostInsertIdentifier)
                                        loc = WriteIdentifier(st, collection.GetIdentifier(entry, i), loc, session);

                                    if (hasIndex)
                                        loc = WriteIndex(st, collection.GetIndex(entry, i), loc, session);

                                    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 collection: {0} rows inserted", count));
                        }
                    }
                    else
                    {
                        if (log.IsDebugEnabled)
                            log.Debug("collection was empty");
                    }
                }
                catch (DbException sqle)
                {
                    throw ADOExceptionHelper.Convert(sqlExceptionConverter, sqle,
                                                     "could not insert collection: " + MessageHelper.InfoString(this, id));
                }
//.........这里部分代码省略.........
开发者ID:zibler,项目名称:zibler,代码行数:101,代码来源:AbstractCollectionPersister.cs

示例6: 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)
                    {
                        int offset = 0;
                        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);
                                offset = WriteKey(st, id, offset, session);
                                if (hasIdentifier && !isPostInsertIdentifier)
                                {
                                    offset = WriteIdentifier(st, collection.GetIdentifier(entry, i), offset, session);
                                }
                                if (hasIndex)
                                {
                                    offset = WriteIndex(st, collection.GetIndex(entry, i), offset, session);
                                }
                                WriteElement(st, collection.GetElement(entry), offset, 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 (DbException sqle)
                {
                    throw ADOExceptionHelper.Convert(sqlExceptionConverter, sqle, "could not insert collection rows: " + MessageHelper.InfoString(this, id));
                }
            }
        }
开发者ID:zibler,项目名称:zibler,代码行数:82,代码来源:AbstractCollectionPersister.cs

示例7: DoUpdateRows


//.........这里部分代码省略.........
							count++;
						}
						i++;
					}
				}
				catch (Exception e)
				{
					if (useBatch)
					{
						session.Batcher.AbortBatch(e);
					}
					throw;
				}
				finally
				{
					if (!useBatch && st != null)
					{
						session.Batcher.CloseCommand(st, null);
					}
				}

				// now update all changed or added rows fks
				count = 0;
				st = null;

				try
				{
					expectation = Expectations.AppropriateExpectation(DeleteCheckStyle);
					useBatch = expectation.CanBeBatched;
					i = 0;
					entries = collection.Entries();
					foreach (object entry in entries)
					{
						int offset = 0;
						if (collection.NeedsUpdating(entry, i, ElementType)) // will still be issued when it used to be null
						{
							if (useBatch)
							{
								if (st == null)
								{
									st =
										session.Batcher.PrepareBatchCommand(SqlInsertRowString.CommandType, SqlInsertRowString.Text,
										                                    SqlInsertRowString.ParameterTypes);
								}
							}
							else
							{
								st = session.Batcher.PrepareCommand(
									SqlInsertRowString.CommandType,
									SqlInsertRowString.Text,
									SqlInsertRowString.ParameterTypes);
							}

							//offset += expectation.Prepare(st, Factory.ConnectionProvider.Driver);
							int loc = WriteKey(st, id, offset, session);
							if (HasIndex /* TODO H3: && !indexContainsFormula*/)
							{
								loc = WriteIndexToWhere(st, collection.GetIndex(entry, i), loc, session);
							}
							WriteElementToWhere(st, collection.GetElement(entry), loc, session);
							if (useBatch)
							{
								session.Batcher.AddToBatch(expectation);
							}
							else
							{
								expectation.VerifyOutcomeNonBatched(session.Batcher.ExecuteNonQuery(st), st);
							}
							count++;
						}
						i++;
					}
				}
				catch (Exception e)
				{
					if (useBatch)
					{
						session.Batcher.AbortBatch(e);
					}
					throw;
				}
				finally
				{
					if (st != null)
					{
						session.Batcher.CloseCommand(st, null);
					}
				}
				return count;
			}
			catch (HibernateException)
			{
				// Do not call Convert on HibernateExceptions
				throw;
			}
			catch (Exception sqle)
			{
				throw Convert(sqle, "could not update collection rows: " + MessageHelper.InfoString(this, id));
			}
		}
开发者ID:Novthirteen,项目名称:sconit_timesseiko,代码行数:101,代码来源:OneToManyPersister.cs


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