Castle.ActiveRecord.ActiveRecordBase.Exists C# (CSharp) Метод

Exists() защищенный статический Метод

Check if the id exists in the database.
protected static Exists ( Type targetType, object id ) : bool
targetType System.Type The target type.
id object The id to check on
Результат bool
		protected internal static bool Exists(Type targetType, object id)
		{
			EnsureInitialized(targetType);
			ISession session = holder.CreateSession(targetType);
			
			try
			{
				return session.Get(targetType, id) != null;	
			}
			catch(Exception ex)
			{
				throw new ActiveRecordException("Could not perform Exists for " + targetType.Name + ". Id: " + id, ex);
			}
			finally
			{
				holder.ReleaseSession(session);
			}
		}

Same methods

ActiveRecordBase::Exists ( Type targetType ) : bool
ActiveRecordBase::Exists ( Type targetType, DetachedCriteria detachedCriteria ) : bool
ActiveRecordBase::Exists ( Type targetType, string filter ) : bool

Usage Example

Пример #1
0
 /// <summary>
 /// Check if any instance matches the query.
 /// </summary>
 /// <param name="targetType">target Type</param>
 /// <param name="detachedQuery">The query expression</param>
 /// <returns><c>true</c> if an instance is found; otherwise <c>false</c>.</returns>
 public static bool Exists(Type targetType, IDetachedQuery detachedQuery)
 {
     return(ActiveRecordBase.Exists(targetType, detachedQuery));
 }
All Usage Examples Of Castle.ActiveRecord.ActiveRecordBase::Exists