Exemplo n.º 1
0
        internal void ReadRelationToOne(CSSchemaField schemaField, ICSDbReader dataReader, Dictionary <string, string> aliasMap)
        {
            try
            {
                CSFieldValue fieldLocal = _fieldData["#" + schemaField.Relation.LocalKey];

                if (fieldLocal.Value != null)
                {
                    CSObject relationObject = CSFactory.New(schemaField.FieldType);

                    if (dataReader != null)
                    {
                        relationObject.FromDataReader(dataReader, aliasMap);
                    }
                    else if (!relationObject.ReadUsingUniqueKey(schemaField.Relation.ForeignKey, fieldLocal.Value))
                    {
                        throw new CSException("Relation " + schemaField.Name + " could not be read");
                    }

                    _fieldData[schemaField.Name].ValueDirect = relationObject;
                    _fieldData[schemaField.Name].ValueState  = CSFieldValueState.Read;
                }
                else
                {
                    _fieldData[schemaField.Name].ValueDirect = null;
                    _fieldData[schemaField.Name].ValueState  = CSFieldValueState.Read;
                }
            }
            catch (TargetInvocationException ex)
            {
                throw ex.InnerException;
            }
        }
Exemplo n.º 2
0
 /// <summary>
 /// Creates a new object
 /// </summary>
 /// <returns>The newly created object</returns>
 public static T New()
 {
     return(CSFactory.New <T>());
 }