private static TnfPropertyObjectType ReadObject(IDataRecord reader)
        {
            var tnfPropertyObjectType = new TnfPropertyObjectType();

            tnfPropertyObjectType.Oid                       = reader["oid"].ToInt();
            tnfPropertyObjectType.CatalogueOid              = reader["catalogue_oid"].ToInt();
            tnfPropertyObjectType.Name                      = reader["name"].FromDbString();
            tnfPropertyObjectType.Description               = reader["description"].FromDbString();
            tnfPropertyObjectType.NetworkReferenceType      = reader["network_reference_type"].ToInt32();
            tnfPropertyObjectType.HasSide                   = reader["has_side"].ToBoolean();
            tnfPropertyObjectType.HasDirection              = reader["has_direction"].ToBoolean();
            tnfPropertyObjectType.MustCover                 = reader["must_cover"].ToBoolean();
            tnfPropertyObjectType.CanOverlap                = reader["can_overlap"].ToBoolean();
            tnfPropertyObjectType.HasHistory                = reader["has_history"].ToBoolean();
            tnfPropertyObjectType.HasLaneCode               = reader["has_lanecode"].ToBoolean();
            tnfPropertyObjectType.NetworkReferenceMin       = reader["network_references_min"].ToInt32();
            tnfPropertyObjectType.NetworkReferenceMax       = reader["network_references_max"].ToInt32();
            tnfPropertyObjectType.ValidFrom                 = reader["valid_from"].ToDateTime();
            tnfPropertyObjectType.ValidTo                   = reader["valid_to"].ToDateTime();
            tnfPropertyObjectType.ShortName                 = reader["shortname"].FromDbString();
            tnfPropertyObjectType.AttributeFormat           = reader["attribute_format"].FromDbString();
            tnfPropertyObjectType.OrderedNetworkReferences  = reader["ordered_network_references"].ToBoolean();
            tnfPropertyObjectType.NetworkReferenceClass     = reader["network_reference_class"].FromDbString();
            tnfPropertyObjectType.BaseCatalogueOid          = reader["base_catalogue_oid"].ToInt32();
            tnfPropertyObjectType.BasePropertyObjectTypeOid = reader["base_property_object_type_oid"].ToInt32();
            tnfPropertyObjectType.IsDerived                 = reader.ReadIfExists("is_derived").ToBoolean() ?? false;

            return(tnfPropertyObjectType);
        }
 public int Update(TnfPropertyObjectType tnfPropertyObjectType)
 {
     return(Update(new object[]
     {
         tnfPropertyObjectType.Oid,
         tnfPropertyObjectType.CatalogueOid,
         tnfPropertyObjectType.Name,
         tnfPropertyObjectType.Description,
         tnfPropertyObjectType.NetworkReferenceType,
         tnfPropertyObjectType.HasSide,
         tnfPropertyObjectType.HasDirection,
         tnfPropertyObjectType.MustCover,
         tnfPropertyObjectType.CanOverlap,
         tnfPropertyObjectType.HasHistory,
         tnfPropertyObjectType.HasLaneCode,
         tnfPropertyObjectType.NetworkReferenceMin,
         tnfPropertyObjectType.NetworkReferenceMax,
         tnfPropertyObjectType.ValidFrom?.Date,
         tnfPropertyObjectType.ValidTo?.Date,
         tnfPropertyObjectType.ShortName,
         tnfPropertyObjectType.AttributeFormat,
         tnfPropertyObjectType.OrderedNetworkReferences,
         tnfPropertyObjectType.NetworkReferenceClass,
         tnfPropertyObjectType.BaseCatalogueOid,
         tnfPropertyObjectType.BasePropertyObjectTypeOid,
         tnfPropertyObjectType.IsDerived
     }));
 }
        private List <TnfPropertyObjectType> GetAll(int catalogueOid, int fromDate, int toDate, bool bTimeInterval)
        {
            var propertyObjectTypes = new List <TnfPropertyObjectType>();

            string commandText = $"SELECT {string.Join(", ", ColumnNames)} " +
                                 $"FROM {TnfPropertyObjectTypeTableName} WHERE catalogue_oid=" +
                                 catalogueOid;

            if (bTimeInterval)
            {
                commandText += " AND valid_from >= " + fromDate + " AND valid_to <= " + toDate;
            }

            using (IDataReader reader = Db.ExecuteReader(commandText))
            {
                while (reader != null && reader.Read())
                {
                    TnfPropertyObjectType propertyObjectType = ReadObject(reader);
                    propertyObjectTypes.Add(propertyObjectType);
                }
            }

            return(propertyObjectTypes);
        }