Esempio n. 1
0
		// ------------------------------------------------------------------

		/// <summary>
		/// Load an object by a given ID.
		/// </summary>
		public static CrmPerson GetByID(
			string id )
		{
			DataRow row = AdoNetSqlHelper.ExecuteRow(
				"GetCrmPersonByID",
				new AdoNetSqlParamCollection(
				AdoNetSqlParamCollection.CreateParameter( "@ID", id )
				) );

			if ( row == null )
			{
				return null;
			}
			else
			{
				CrmPerson o = new CrmPerson();
				o.Load( row );

				if ( o.IsEmpty )
				{
					return null;
				}
				else
				{
					return o;
				}
			}
		}
Esempio n. 2
0
		/// <summary>
		/// Load all for the given parent.
		/// </summary>
		public static CrmPerson[] GetForAddress(
			CrmAddress parentObject )
		{
			DataTable table = AdoNetSqlHelper.ExecuteTable(
				"GetCrmPersonByCrmAddressID",
				new AdoNetSqlParamCollection(
				AdoNetSqlParamCollection.CreateParameter( "@ID", parentObject.ID )
				) );

			if ( table == null )
			{
				return null;
			}
			else
			{
				ArrayList result = new ArrayList();

				foreach ( DataRow row in table.Rows )
				{
					CrmPerson o = new CrmPerson();
					o.Load( row );

					if ( !o.IsEmpty )
					{
						result.Add( o );
					}
				}

				if ( result.Count <= 0 )
				{
					return null;
				}
				else
				{
					return (CrmPerson[])result.ToArray(
						typeof( CrmPerson ) );
				}
			}
		}