public Codelist Get_CODELIST(string code, bool isDimensionCode)
        {
            Codelist codelsit = new Codelist();

            //IList<Code> return_codes = null;
            if (this._ds != null)
            {
                if (code == "TIME_PERIOD")
                {
                    codelsit.Identify = new SDMXIdentifier() { id = "TIME_PERIOD", agencyid = "", version = "" };
                    foreach (TimePeriod time in ISTAT.DBDAL.DataAccess.Get_TimePeriod())
                        codelsit.Items.Add(new Code() { Id = time.CODE });
                }
                else
                {

                    List<ConceptDimensionDB> _dimsPart = ISTAT.DBDAL.DataAccess.Get_DimensionsPartial(_ds.IDSet);
                    List<ConceptAttributeDB> _attsPart = ISTAT.DBDAL.DataAccess.Get_AttributesPartial(_ds.IDSet);

                    if (isDimensionCode)
                    {
                        #region Ricerca di una dimension Codelist
                        // cerco nelle dimensioni
                        foreach (Dimension dim in this._ds.Dimensions)
                        {
                            if (dim.Id == code)
                            {
                                if (dim.Codelist != null && dim.CodelistAgency != null && dim.CodelistVersion != null)
                                {
                                    codelsit.Identify = new SDMXIdentifier() { agencyid = dim.CodelistAgency, id = dim.Codelist, version = dim.CodelistVersion };

                                    IList<Org.Sdmxsource.Sdmx.Api.Model.Objects.Codelist.ICode> _codes = ISTAT.DBDAL.DataSDMX.GetCodelist(codelsit.Identify).Items;

                                    foreach (Org.Sdmxsource.Sdmx.Api.Model.Objects.Codelist.ICode icode in _codes)
                                        codelsit.Items.Add(new Code(icode));
                                }
                                else {
                                    ConceptDimensionDB db_dim = (ConceptDimensionDB)(from d in _dimsPart where d.Code == code select d).OfType<ConceptDimensionDB>().First();

                                    string[] str = db_dim.MemberTable.Split('_');

                                    if (str.Length > 3)
                                    {
                                        str[0] = "CL_" + str[0].Substring(3, str[0].Length - 3);
                                        for (int i = 1; i < str.Length - 2; i++) {
                                            str[0] += "_" + str[i];
                                        }
                                    }
                                    else {
                                        str[0] = "CL_" + str[0].Substring(3, str[0].Length - 3);
                                    }

                                    str[str.Length - 1] = (str[str.Length - 1][0].ToString() + "." + str[str.Length - 1][1].ToString()).ToString();

                                    codelsit.Identify = new SDMXIdentifier() { id = str[0], agencyid = str[str.Length - 2], version = str[str.Length - 1] };
                                    IList<Org.Sdmxsource.Sdmx.Api.Model.Objects.Codelist.ICode> _codes = ISTAT.DBDAL.DataSDMX.GetCodelist(codelsit.Identify).Items;

                                    foreach (Org.Sdmxsource.Sdmx.Api.Model.Objects.Codelist.ICode icode in _codes)
                                        codelsit.Items.Add(new Code(icode));
                                }
                            }
                        }

                        #endregion
                    }
                    else
                    {
                        #region Ricerca di una attribut codelist

                        if (this._ds.Attributes != null)
                        {
                            // cerco nelle dimensioni
                            foreach (ISTAT.ENTITY.Attribute att in this._ds.Attributes)
                            {
                                if (att.Id == code)
                                {
                                    if (att.Codelist != null && att.CodelistAgency != null && att.CodelistVersion != null)
                                    {
                                        codelsit.Identify = new SDMXIdentifier() { agencyid = att.CodelistAgency, id = att.Codelist, version = att.CodelistVersion };
                                        codelsit.Items = att.Codes;
                                        IList<Org.Sdmxsource.Sdmx.Api.Model.Objects.Codelist.ICode> _codes = ISTAT.DBDAL.DataSDMX.GetCodelist(codelsit.Identify).Items;

                                        codelsit.Items = new List<Code>();
                                        foreach (Org.Sdmxsource.Sdmx.Api.Model.Objects.Codelist.ICode icode in _codes)
                                            codelsit.Items.Add(new Code(icode));
                                    }
                                    else {
                                        ConceptAttributeDB db_att = (ConceptAttributeDB)(from a in _attsPart where a.Code == code select a).OfType<ConceptAttributeDB>().First();

                                        string[] str = db_att.MemberTable.Split('_');

                                        if (str.Length > 3)
                                        {
                                            str[0] = "CL_" + str[0].Substring(3, str[0].Length - 3);
                                            for (int i = 1; i < str.Length - 2; i++)
                                            {
                                                str[0] += "_" + str[i];
                                            }
                                        }
                                        else
                                        {
                                            str[0] = "CL_" + str[0].Substring(3, str[0].Length - 3);
                                        }

                                        str[str.Length - 1] = (str[str.Length - 1][0].ToString() + "." + str[str.Length - 1][1].ToString()).ToString();

                                        codelsit.Identify = new SDMXIdentifier() { id = str[0], agencyid = str[str.Length - 2], version = str[str.Length - 1] };
                                        IList<Org.Sdmxsource.Sdmx.Api.Model.Objects.Codelist.ICode> _codes = ISTAT.DBDAL.DataSDMX.GetCodelist(codelsit.Identify).Items;

                                        foreach (Org.Sdmxsource.Sdmx.Api.Model.Objects.Codelist.ICode icode in _codes)
                                            codelsit.Items.Add(new Code(icode));
                                    }
                                }
                            }
                        }

                        #endregion
                    }
                }
            }
            return codelsit;
        }
        public void Merge(ICodelistObject codelist)
        {
            Codelist _codelist = new Codelist(codelist);
            _codelistItems = _codelist.Items;
            this._names = new List<TextTypeWrapper>();
            foreach (ITextTypeWrapper text in codelist.Names)
            {
                this._names.Add(new TextTypeWrapper(text.Locale, text.Value));
            }

            this._descriptions = new List<TextTypeWrapper>();
            foreach (ITextTypeWrapper text in codelist.Descriptions)
            {
                this._descriptions.Add(new TextTypeWrapper(text.Locale, text.Value));
            }
        }