Castle.ActiveRecord.ActiveRecordBase.FindOne C# (CSharp) Method

FindOne() protected static method

Searches and returns a row. If more than one is found, throws ActiveRecordException
protected static FindOne ( Type targetType ) : object
targetType System.Type The target type
return object
		protected internal static object FindOne(Type targetType, params ICriterion[] criteria)
		{
			Array result = SlicedFindAll(targetType, 0, 2, criteria);

			if (result.Length > 1)
			{
				throw new ActiveRecordException(targetType.Name + ".FindOne returned " + result.Length +
												" rows. Expecting one or none");
			}

			return (result.Length == 0) ? null : result.GetValue(0);
		}

Same methods

ActiveRecordBase::FindOne ( Type targetType, DetachedCriteria criteria ) : object

Usage Example

Ejemplo n.º 1
0
 /// <summary>
 /// Searches and returns a row. If more than one is found,
 /// throws <see cref="ActiveRecordException"/>
 /// </summary>
 /// <param name="targetType">The target type</param>
 /// <param name="criteria">The criteria</param>
 /// <returns>A <c>targetType</c> instance or <c>null</c></returns>
 public static object FindOne(Type targetType, DetachedCriteria criteria)
 {
     return(ActiveRecordBase.FindOne(targetType, criteria));
 }
All Usage Examples Of Castle.ActiveRecord.ActiveRecordBase::FindOne