/// <summary> /// Constructs a new condition that can be used in a where-clause. /// </summary> /// <param name="p_column_name">The column the new condition should check (fe "id").</param> /// <param name="p_operation">The operation the new condition should perform (fe "=" or "<").</param> /// <param name="p_expected_value">The value the new condition should check against (fe 5, "test", othercolumn).</param> /// <param name="p_nested_condition">The condition that this condition should be chained with, or null.</param> /// <param name="boolean_operator">The operator that this condition should use to chain with the given nested condition.</param> internal CWhereCondition(String p_column_name, String p_operation, Object p_expected_value, CWhereCondition p_nested_condition, EBooleanOperator boolean_operator) { m_p_column_name = p_column_name; m_p_operation = p_operation; m_p_expected_value = p_expected_value; m_p_nested_condition = p_nested_condition; m_boolean_operator = boolean_operator; }
/// <summary> /// Constructs a new condition that can be used in a where-clause. /// </summary> /// <param name="p_conditions">The conditions that this condition should be composed of. Needs to have at least one element.</param> internal CWhereCondition(CWhereCondition[] p_conditions) { m_p_column_name = p_conditions[0].m_p_column_name; m_p_operation = p_conditions[0].m_p_operation; m_p_expected_value = p_conditions[0].m_p_expected_value; m_boolean_operator = p_conditions[0].m_boolean_operator; for (Int32 i = p_conditions.Length - 1; i > 0; --i) { m_p_nested_condition = new SQL.CWhereCondition( p_conditions[i].m_p_column_name, p_conditions[i].m_p_operation, p_conditions[i].m_p_expected_value, m_p_nested_condition, p_conditions[i].m_boolean_operator ); } }
/// <summary> /// Loads an Object of the given type with the given criteria. The criteria must uniquely identify an Object, otherwise an exception is thrown. /// </summary> /// <typeparam name="T">The type of the Object to load.</typeparam> /// <param name="p_object_conditions">The criteria the loaded Object must match.</param> /// <returns>The loaded Object that matched the criteria. If no Object matches the criteria, default(T) is returned, if multiple objects matched, an error is thrown.</returns> public async Task <CDBWizardStatus> LoadClassAsync <T>(T p_obj, params KeyValuePair <String, Object>[] p_object_conditions) where T : class { CObjectMap p_object_map = CObjectMap.Get(p_obj.GetType()); if (p_object_map.m_p_begin_load_call_back != null) { p_object_map.m_p_begin_load_call_back(p_obj); } SQL.CWhereCondition[] p_conditions = new SQL.CWhereCondition[p_object_conditions.Length]; for (Int32 i = 0; i < p_object_conditions.Length; ++i) { p_conditions[i] = new SQL.CWhereCondition(p_object_conditions[i].Key, "=", p_object_conditions[i].Value); } CDataBaseObject p_db_obj = new CDataBaseObject(p_object_map); CDBWizardStatus p_status = await p_object_map.LoadObjectAsync( this, new SQL.CWhereCondition(p_conditions), p_db_obj ); if (!p_status.IsError) { try { p_db_obj.MapToClass(p_obj); if (p_object_map.m_p_end_load_call_back != null) { p_object_map.m_p_end_load_call_back(p_obj); } } catch (Exception p_except) { return(new CDBWizardStatus(EDBWizardStatusCode.err_exception_thrown, p_except)); } } return(p_status); }