<commit_before>using System;
using System.Collections.Generic;
using System.Linq;
using System.Runtime.CompilerServices;
using System.Threading;
using Umbraco.Core;
using Umbraco.Core.Cache;
using Umbraco.Core.Models;

using umbraco.BusinessLogic;
using umbraco.cms.businesslogic.cache;
using umbraco.cms.businesslogic.property;
using umbraco.cms.businesslogic.web;
using umbraco.cms.helpers;
using umbraco.DataLayer;
using umbraco.interfaces;
using DataTypeDefinition = umbraco.cms.businesslogic.datatype.DataTypeDefinition;
using Language = umbraco.cms.businesslogic.language.Language;

namespace umbraco.cms.businesslogic.propertytype
{
    /// <summary>
    /// Summary description for propertytype.
    /// </summary>
    [Obsolete("Use the ContentTypeService instead")]
    public class PropertyType
    {
        #region Declarations
        
        private readonly int _contenttypeid;
        private readonly int _id;
        private int _DataTypeId;
        private string _alias;
        private string _description = "";
        private bool _mandatory;
        private string _name;
        private int _sortOrder;
        private int _tabId;
        private int _propertyTypeGroup;
        private string _validationRegExp = "";

        #endregion

        /// <summary>
        /// Unused, please do not use
        /// </summary>
        [Obsolete("Obsolete, For querying the database use the new UmbracoDatabase object ApplicationContext.Current.DatabaseContext.Database", false)]
        protected static ISqlHelper SqlHelper
        {
            get { return Application.SqlHelper; }
        }

        #region Constructors

        public PropertyType(int id)
        {
            var found = ApplicationContext.Current.DatabaseContext.Database
                .SingleOrDefault<dynamic>(
                    "Select mandatory, DataTypeId, propertyTypeGroupId, contentTypeId, sortOrder, alias, name, validationRegExp, description from cmsPropertyType where id=@id",
                    new {id = id});

            if (found == null)
                throw new ArgumentException("Propertytype with id: " + id + " doesnt exist!");

            _mandatory = found.mandatory;
            _id = id;

            if (found.propertyTypeGroupId != null)
            {
                _propertyTypeGroup = found.propertyTypeGroupId;
                //TODO: Remove after refactoring!
                _tabId = _propertyTypeGroup;
            }

            _sortOrder = found.sortOrder;
            _alias = found.alias;
            _name = found.name;
            _validationRegExp = found.validationRegExp;
            _DataTypeId = found.DataTypeId;
            _contenttypeid = found.contentTypeId;
            _description = found.description;
        }

        #endregion

        #region Properties

        public DataTypeDefinition DataTypeDefinition
        {
            get { return DataTypeDefinition.GetDataTypeDefinition(_DataTypeId); }
            set
            {
                _DataTypeId = value.Id;
                using (var sqlHelper = Application.SqlHelper)
                    sqlHelper.ExecuteNonQuery(
                        "Update cmsPropertyType set DataTypeId = " + value.Id + " where id=" + Id);
            }
        }
<commit_msg>Fixed issue U4-9493<commit_after>using System;
using System.Collections.Generic;
using System.Linq;
using System.Runtime.CompilerServices;
using System.Threading;
using Umbraco.Core;
using Umbraco.Core.Cache;
using Umbraco.Core.Models;

using umbraco.BusinessLogic;
using umbraco.cms.businesslogic.cache;
using umbraco.cms.businesslogic.property;
using umbraco.cms.businesslogic.web;
using umbraco.cms.helpers;
using umbraco.DataLayer;
using umbraco.interfaces;
using DataTypeDefinition = umbraco.cms.businesslogic.datatype.DataTypeDefinition;
using Language = umbraco.cms.businesslogic.language.Language;

namespace umbraco.cms.businesslogic.propertytype
{
    /// <summary>
    /// Summary description for propertytype.
    /// </summary>
    [Obsolete("Use the ContentTypeService instead")]
    public class PropertyType
    {
        #region Declarations
        
        private readonly int _contenttypeid;
        private readonly int _id;
        private int _DataTypeId;
        private string _alias;
        private string _description = "";
        private bool _mandatory;
        private string _name;
        private int _sortOrder;
        private int _tabId;
        private int _propertyTypeGroup;
        private string _validationRegExp = "";

        #endregion

        /// <summary>
        /// Unused, please do not use
        /// </summary>
        [Obsolete("Obsolete, For querying the database use the new UmbracoDatabase object ApplicationContext.Current.DatabaseContext.Database", false)]
        protected static ISqlHelper SqlHelper
        {
            get { return Application.SqlHelper; }
        }

        #region Constructors

        public PropertyType(int id)
        {
            var found = ApplicationContext.Current.DatabaseContext.Database
                .SingleOrDefault<dynamic>(
                    "Select mandatory, DataTypeId, propertyTypeGroupId, contentTypeId, sortOrder, alias, name, validationRegExp, description from cmsPropertyType where id=@id",
                    new {id = id});

            if (found == null)
                throw new ArgumentException("Propertytype with id: " + id + " doesnt exist!");

            _mandatory = found.mandatory;
            _id = id;

            if (found.propertyTypeGroupId != null)
            {
                _propertyTypeGroup = found.propertyTypeGroupId;
                //TODO: Remove after refactoring!
                _tabId = _propertyTypeGroup;
            }

            _sortOrder = found.sortOrder;
            _alias = found.Alias;
            _name = found.Name;
            _validationRegExp = found.validationRegExp;
            _DataTypeId = found.dataTypeId;
            _contenttypeid = found.contentTypeId;
            _description = found.Description;
        }

        #endregion

        #region Properties

        public DataTypeDefinition DataTypeDefinition
        {
            get { return DataTypeDefinition.GetDataTypeDefinition(_DataTypeId); }
            set
            {
                _DataTypeId = value.Id;
                using (var sqlHelper = Application.SqlHelper)
                    sqlHelper.ExecuteNonQuery(
                        "Update cmsPropertyType set DataTypeId = " + value.Id + " where id=" + Id);
            }
        }

{'fraction_non_alphanumeric': 0.07719244823386115, 'fraction_numerical': 0.0007612667478684531, 'mean_word_length': 2.1370582617000955, 'pattern_counts': {'":': 0, '<': 13, '<?xml version=': 0, '>': 13, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4624878', 'n_tokens_mistral': 1698, 'n_tokens_neox': 1648, 'n_words': 414}