/// <summary>
		/// Selects NWS_Profile values from Database and assigns them to the appropriate DO_NWS_Profile property.
		/// </summary>
		/// <param name="IFProfile_in">IFProfile</param>
		/// <param name="dbConnection_in">Database connection, making the use of Database Transactions possible on a sequence of operations across the same or multiple DataObjects</param>
		/// <returns>null if NWS_Profile doesn't exists at Database</returns>
		public static SO_NWS_Profile getObject(
			long IFProfile_in, 
			DBConnection dbConnection_in
		) {
			SO_NWS_Profile _output = null;

			DBConnection _connection = (dbConnection_in == null)
				? DO__utils.DBConnection_createInstance(
					DO__utils.DBServerType,
					DO__utils.DBConnectionstring,
					DO__utils.DBLogfile
				) 
				: dbConnection_in;
			IDbDataParameter[] _dataparameters = new IDbDataParameter[] {
				_connection.newDBDataParameter("IFProfile_", DbType.Int64, ParameterDirection.InputOutput, IFProfile_in, 0), 
				_connection.newDBDataParameter("IFUser__Approved_", DbType.Int64, ParameterDirection.Output, null, 0), 
				_connection.newDBDataParameter("Approved_date_", DbType.DateTime, ParameterDirection.Output, null, 0)
			};
			_connection.Execute_SQLFunction("sp0_NWS_Profile_getObject", _dataparameters);
			if (dbConnection_in == null) { _connection.Dispose(); }

			if (_dataparameters[0].Value != DBNull.Value) {
				_output = new SO_NWS_Profile();

				if (_dataparameters[0].Value == System.DBNull.Value) {
					_output.IFProfile = 0L;
				} else {
					_output.IFProfile = (long)_dataparameters[0].Value;
				}
				if (_dataparameters[1].Value == System.DBNull.Value) {
					_output.IFUser__Approved_isNull = true;
				} else {
					_output.IFUser__Approved = (long)_dataparameters[1].Value;
				}
				if (_dataparameters[2].Value == System.DBNull.Value) {
					_output.Approved_date_isNull = true;
				} else {
					_output.Approved_date = (DateTime)_dataparameters[2].Value;
				}

				_output.haschanges_ = false;
				return _output;
			}

			return null;
		}
		private static SO_NWS_Profile[] getRecord(
			DataTable dataTable_in
		) {
			DataColumn _dc_ifprofile = null;
			DataColumn _dc_ifuser__approved = null;
			DataColumn _dc_approved_date = null;

			SO_NWS_Profile[] _output 
				= new SO_NWS_Profile[dataTable_in.Rows.Count];
			for (int r = 0; r < dataTable_in.Rows.Count; r++) {
				if (r == 0) {
					_dc_ifprofile = dataTable_in.Columns["IFProfile"];
					_dc_ifuser__approved = dataTable_in.Columns["IFUser__Approved"];
					_dc_approved_date = dataTable_in.Columns["Approved_date"];
				}

				_output[r] = new SO_NWS_Profile();
				if (dataTable_in.Rows[r][_dc_ifprofile] == System.DBNull.Value) {
					_output[r].ifprofile_ = 0L;
				} else {
					_output[r].ifprofile_ = (long)dataTable_in.Rows[r][_dc_ifprofile];
				}
				if (dataTable_in.Rows[r][_dc_ifuser__approved] == System.DBNull.Value) {
					_output[r].IFUser__Approved_isNull = true;
				} else {
					_output[r].ifuser__approved_ = (long)dataTable_in.Rows[r][_dc_ifuser__approved];
				}
				if (dataTable_in.Rows[r][_dc_approved_date] == System.DBNull.Value) {
					_output[r].Approved_date_isNull = true;
				} else {
					_output[r].approved_date_ = (DateTime)dataTable_in.Rows[r][_dc_approved_date];
				}

				_output[r].haschanges_ = false;
			}

			return _output;
		}
		/// <summary>
		/// Inserts/Updates NWS_Profile values into/on Database. Inserts if NWS_Profile doesn't exist or Updates if NWS_Profile already exists.
		/// </summary>
		/// <param name="forceUpdate_in">assign with True if you wish to force an Update (even if no changes have been made since last time getObject method was run) and False if not</param>
		/// <param name="dbConnection_in">Database connection, making the use of Database Transactions possible on a sequence of operations across the same or multiple DataObjects</param>
		/// <returns>True if it didn't exist (INSERT), and False if it did exist (UPDATE)</returns>
		public static bool setObject(
			SO_NWS_Profile NWS_Profile_in, 
			bool forceUpdate_in, 
			DBConnection dbConnection_in
		) {
			bool ConstraintExist_out;
			if (forceUpdate_in || NWS_Profile_in.haschanges_) {
				DBConnection _connection = (dbConnection_in == null)
					? DO__utils.DBConnection_createInstance(
						DO__utils.DBServerType,
						DO__utils.DBConnectionstring,
						DO__utils.DBLogfile
					) 
					: dbConnection_in;
				IDbDataParameter[] _dataparameters = new IDbDataParameter[] {
					_connection.newDBDataParameter("IFProfile_", DbType.Int64, ParameterDirection.Input, NWS_Profile_in.IFProfile, 0), 
					_connection.newDBDataParameter("IFUser__Approved_", DbType.Int64, ParameterDirection.Input, NWS_Profile_in.IFUser__Approved_isNull ? null : (object)NWS_Profile_in.IFUser__Approved, 0), 
					_connection.newDBDataParameter("Approved_date_", DbType.DateTime, ParameterDirection.Input, NWS_Profile_in.Approved_date_isNull ? null : (object)NWS_Profile_in.Approved_date, 0), 

					//_connection.newDBDataParameter("Exists", DbType.Boolean, ParameterDirection.Output, 0, 1)
					_connection.newDBDataParameter("Output_", DbType.Int32, ParameterDirection.Output, null, 0)
				};
				_connection.Execute_SQLFunction(
					"sp0_NWS_Profile_setObject", 
					_dataparameters
				);
				if (dbConnection_in == null) { _connection.Dispose(); }

				ConstraintExist_out = (((int)_dataparameters[3].Value & 2) == 1);
				if (!ConstraintExist_out) {
					NWS_Profile_in.haschanges_ = false;
				}

				return (((int)_dataparameters[3].Value & 1) != 1);
			} else {
				ConstraintExist_out = false;

				return  false;
			}
		}
		/// <summary>
		/// Inserts/Updates NWS_Profile values into/on Database. Inserts if NWS_Profile doesn't exist or Updates if NWS_Profile already exists.
		/// </summary>
		/// <param name="forceUpdate_in">assign with True if you wish to force an Update (even if no changes have been made since last time getObject method was run) and False if not</param>
		/// <returns>True if it didn't exist (INSERT), and False if it did exist (UPDATE)</returns>
		public static bool setObject(
			SO_NWS_Profile NWS_Profile_in, 
			bool forceUpdate_in
		) {
			return setObject(
				NWS_Profile_in, 
				forceUpdate_in, 
				null
			);
		}
		public static long insObject(
			string sessionGuid_in,
			string ip_forLogPurposes_in, 

			SO_vNWS_Profile profile_in, 

			out int[] errors_out
		) {
			long _output = -1L;

			Guid _sessionguid;
			Sessionuser _sessionuser;

			#region check...
			List<int> _errorlist;
			if (!check(
				sessionGuid_in,
				ip_forLogPurposes_in, 

				ref profile_in,

				out _sessionguid,
				out _sessionuser,
				out _errorlist
			)) {
				errors_out = _errorlist.ToArray();
				return _output;
			} 
			#endregion

			#region SO_CRD_Profile _crd_profile = new SO_CRD_Profile(...);
			SO_CRD_Profile _crd_profile
				= new SO_CRD_Profile(
					-1L,
					profile_in.Name,
					//profile_in.IDApplication
					_sessionuser.IDApplication
				); 
			#endregion
			#region _crd_profile.IFApplication = ...;
			//if (
			//    (profile_in.IDApplication_isNull)
			//    ||
			//    (profile_in.IDApplication <= 0)
			//) {
			//    _crd_profile.IFApplication_isNull = true;
			//} else {
			//    _crd_profile.IFApplication = profile_in.IDApplication;
			//}

			_crd_profile.IFApplication = _sessionuser.IDApplication;
			#endregion
			_crd_profile.Name = profile_in.Name;

			#region SO_NWS_Profile _nws_profile = new SO_NWS_Profile(...);
			SO_NWS_Profile _nws_profile 
				= new SO_NWS_Profile(
				); 
			#endregion
			#region _nws_profile.IFUser__Approved = ...;
			if (_sessionuser.hasPermition(PermitionType.News__Profile__approve)) {
				_nws_profile.Approved_date = DateTime.Now;
				_nws_profile.IFUser__Approved = _sessionuser.IDUser;
			} else {
				//// ALREADY CHECKED!!!
				//if (
				//    !profile_in.Approved_date_isNull
				//    ||
				//    !profile_in.IFUser__Approved_isNull
				//) {
				//    _errorlist.Add(ErrorType.news__profile__lack_of_permitions_to_approve);
				//    errors_out = _errorlist.ToArray();
				//    return _output;
				//} else {
					_nws_profile.Approved_date_isNull = true;
					_nws_profile.IFUser__Approved_isNull = true;
				//}
			} 
			#endregion

			Exception _exception = null;
			#region DBConnection _con = DO__utils.DBConnection_createInstance(...);
			DBConnection _con = DO__utils.DBConnection_createInstance(
				DO__utils.DBServerType,
				DO__utils.DBConnectionstring,
				DO__utils.DBLogfile
			);
			#endregion
			try {
				_con.Open();
				_con.Transaction.Begin();

				_output = DO_CRD_Profile.insObject(
					_crd_profile,
					true,

					_con
				);

				_nws_profile.IFProfile = _output;
				DO_NWS_Profile.setObject(
					_nws_profile,
					true,

					_con
				);

				_errorlist.Add(ErrorType.news__profile__successfully_created__WARNING);

				#region _con.Transaction.Commit();
				if (
					_con.isOpen
					&&
					_con.Transaction.inTransaction
				) {
					_con.Transaction.Commit();
				}
				#endregion
			} catch (Exception _ex) {
				#region _con.Transaction.Rollback();
				if (
					_con.isOpen
					&&
					_con.Transaction.inTransaction
				) {
					_con.Transaction.Rollback();
				}
				#endregion

				_exception = _ex;
			} finally {
				#region _con.Transaction.Terminate(); _con.Close(); _con.Dispose();
				if (_con.isOpen) {
					if (_con.Transaction.inTransaction) {
						_con.Transaction.Terminate();
					}
					_con.Close();
				}

				_con.Dispose();
				#endregion
			}
			if (_exception != null) {
				#region SBO_LOG_Log.Log(ErrorType.data);
				OGen.NTier.Kick.lib.businesslayer.SBO_LOG_Log.log(
					_sessionuser,
					LogType.error,
					ErrorType.data,
					-1L, 
					_sessionuser.IDApplication,
					"{0}",
					new string[] {
			            _exception.Message
			        }
				);
				#endregion
				_errorlist.Add(ErrorType.data);
			}

			errors_out = _errorlist.ToArray();
			return _output;
		}
		public static DataTable getDataTable(
			SO_NWS_Profile[] serializableobjects_in
		) {
			DataTable _output = new DataTable();
			DataRow _dr;

			DataColumn _dc_ifprofile = new DataColumn("IFProfile", typeof(long));
			_output.Columns.Add(_dc_ifprofile);
			DataColumn _dc_ifuser__approved = new DataColumn("IFUser__Approved", typeof(long));
			_output.Columns.Add(_dc_ifuser__approved);
			DataColumn _dc_approved_date = new DataColumn("Approved_date", typeof(DateTime));
			_output.Columns.Add(_dc_approved_date);

			foreach (SO_NWS_Profile _serializableobject in serializableobjects_in) {
				_dr = _output.NewRow();

				_dr[_dc_ifprofile] = _serializableobject.IFProfile;
				_dr[_dc_ifuser__approved] = _serializableobject.IFUser__Approved;
				_dr[_dc_approved_date] = _serializableobject.Approved_date;

				_output.Rows.Add(_dr);
			}

			return _output;
		}