// Recursively get all inherited content types.
        private static void GetAllInheritedContentTypeIds(ICollection <int> ids, IDbConnection conn, int id, Guid contentTypeGuid)
        {
            if (id == -1)
            {
                return;
            }
            ids.Add(id);

            string getPropSql = Properties.Resources.InheritedContentTypeSql;

            List <int> parentIds = new List <int>();

            using (IDbCommand cmd = conn.CreateCommand())
            {
                cmd.CommandText = getPropSql;
                var parm = cmd.CreateParameter();
                parm.ParameterName = "contentTypeGuid";
                parm.Value         = contentTypeGuid;
                cmd.Parameters.Add(parm);
                parm = cmd.CreateParameter();
                parm.ParameterName = "id";
                parm.Value         = id;
                cmd.Parameters.Add(parm);
                using (IDataReader reader = cmd.ExecuteReader())
                {
                    while (reader.Read())
                    {
                        var record = reader;

                        var contentTypePropertyDTO = new ContentTypePropertyDTO();
                        int parentId = -1;
                        if (record["ParentId"] is int)
                        {
                            parentId = (int)record["ParentId"];
                        }
                        parentIds.Add(parentId);
                    }
                }
            }

            foreach (int parentId in parentIds)
            {
                GetAllInheritedContentTypeIds(ids, conn, parentId, contentTypeGuid);
            }
        }
        private static void GetContentTypeProperties <T>(T t, IEnumerable <int> ids, IDbConnection conn, int parentId, Guid contentTypeGuid)
            where T : ContentTypeDTO
        {
            if (parentId == -1)
            {
                return;
            }
//			string getPropSql = @"
//select un.Id, un.[Text] as ContentType,
//cpt.Alias as PropertyAlias,
//cpt.Description as PropertyDescription,
//un3.Text as PropertyType,
//cdt.PropertyEditorAlias as PropertyEditorAlias
//from umbracoNode un
// inner join cmspropertytype cpt on un.id = cpt.contentTypeId
// left join cmsdatatype cdt on cpt.dataTypeId = cdt.nodeId
// left join umbracoNode un3 on cpt.dataTypeId = un3.id
//where un.NodeObjectType = '{0}'
//and un.Id in ({1})";

            string getPropSql = Properties.Resources.ContentTypePropertiesSql;

            IDbCommand    cmd  = conn.CreateCommand();
            StringBuilder sb   = new StringBuilder();
            var           parm = cmd.CreateParameter();

            parm.ParameterName = "contentTypeGuid";
            parm.Value         = contentTypeGuid;
            cmd.Parameters.Add(parm);
            var parameters = new string[ids.Count()];

            for (int i = 0; i < ids.Count(); i++)
            {
                parm = cmd.CreateParameter();
                parm.ParameterName = string.Format("@ids{0}", i);
                parm.Value         = ids.ElementAt(i);
                cmd.Parameters.Add(parm);
                if (sb.Length > 0)
                {
                    sb.Append(',');
                }
                sb.Append(parm.ParameterName);
            }
            cmd.CommandText = string.Format(getPropSql, sb.ToString());
            using (IDataReader reader = cmd.ExecuteReader())
            {
                while (reader.Read())
                {
                    var record = reader;

                    var contentTypePropertyDTO = new ContentTypePropertyDTO();
                    contentTypePropertyDTO.DataTypeId        = (int)record["DataTypeId"];
                    contentTypePropertyDTO.PropertyAlias     = record["PropertyAlias"].ToString();
                    contentTypePropertyDTO.PropertyAliasText = Helpers.GetValidCSharpIdentifier(contentTypePropertyDTO.PropertyAlias);
                    if (!string.IsNullOrWhiteSpace(contentTypePropertyDTO.PropertyAliasText))
                    {
                        contentTypePropertyDTO.PropertyAliasText = contentTypePropertyDTO.PropertyAliasText[0].ToString().ToUpper() + contentTypePropertyDTO.PropertyAliasText.Substring(1);
                    }
                    contentTypePropertyDTO.PropertyDescription = record["PropertyDescription"].ToString();
                    contentTypePropertyDTO.PropertyType        = record["PropertyType"].ToString();

                    var propertyType = Helpers.GetPropertyType(record["PropertyEditorAlias"].ToString());
                    contentTypePropertyDTO.Type = propertyType;


                    contentTypePropertyDTO.PropertyTypeAlias = propertyType.Name;

                    t.Properties.Add(contentTypePropertyDTO);
                }
            }
        }