public List<CustomizableFieldSearchResult> SelectCreatedEntites()
        {
            string sqlText = @"SELECT
                                 AdvancedFieldsEntities.id,
                                 AdvancedFieldsEntities.name,
                                 COUNT(AdvancedFieldsEntities.id) AS fields_number
                               FROM AdvancedFieldsEntities
                               INNER JOIN dbo.AdvancedFields ON dbo.AdvancedFieldsEntities.id = dbo.AdvancedFields.entity_id
                               GROUP BY
                                 AdvancedFieldsEntities.id,
                                 AdvancedFieldsEntities.name
                               ORDER BY dbo.AdvancedFieldsEntities.id";

            List<CustomizableFieldSearchResult> entities = new List<CustomizableFieldSearchResult>();
            using (SqlConnection conn = GetConnection())
            using (OpenCbsCommand cmd = new OpenCbsCommand(sqlText, conn))
            {
                using (OpenCbsReader reader = cmd.ExecuteReader())
                {
                    if (reader.Empty) return new List<CustomizableFieldSearchResult>();
                    while (reader.Read())
                    {
                        CustomizableFieldSearchResult result = new CustomizableFieldSearchResult();
                        result.EntityName = reader.GetString("name");
                        result.FieldsNumber = reader.GetInt("fields_number");
                        result.Fields = SelectFieldNamesForEntity(reader.GetInt("id"));
                        entities.Add(result);
                    }
                }
            }

            return entities;
        }
        private void LoadFields()
        {
            List<CustomizableFieldSearchResult> results = new List<CustomizableFieldSearchResult>();

            List<CustomizableFieldSearchResult> entities = ServicesProvider.GetInstance().GetCustomizableFieldsServices().SelectCreatedEntites();
            foreach (var entity in entities)
            {
                CustomizableFieldSearchResult result = new CustomizableFieldSearchResult();
                result.EntityName = GetString("entity" + entity.EntityName);
                result.Fields = entity.Fields;
                result.FieldsNumber = entity.FieldsNumber;
                results.Add(result);
            }

            olvFieldGroups.Items.Clear();
            olvFieldGroups.SetObjects(results);
            CheckSelected();
        }