Example #1
0
        /// <summary>
        /// Binds the data.
        /// </summary>
        private void BindData()
        {
            DataTable dt = new DataTable();

            dt.Columns.AddRange(new DataColumn[] { new DataColumn("Key", typeof(string)), new DataColumn("Value", typeof(string)) });

            if (MetaObject != null)
            {
                MetaStringDictionary dict = (MetaStringDictionary)MetaObject.GetStringDictionary(MetaField);
                if (dict != null)
                {
                    foreach (string key in dict.Keys)
                    {
                        DataRow row = dt.NewRow();
                        row["Key"]   = key;
                        row["Value"] = dict[key];
                        dt.Rows.Add(row);
                    }
                }
            }

            DictionaryItemsTable = dt;

            this.ItemsGrid.DataSource = dt;
            this.ItemsGrid.DataBind();
        }
Example #2
0
        /// <summary>
        /// Updates this instance.
        /// </summary>
        public void Update()
        {
            if (DictionaryItemsTable != null)
            {
                MetaStringDictionary dict = new MetaStringDictionary();
                foreach (DataRow row in DictionaryItemsTable.Rows)
                {
                    dict.Add((string)row["Key"], (string)row["Value"]);
                }

                MetaHelper.SetMetaFieldValue(MetaField.Context, MetaObject, MetaField.Name, new object[] { dict });
            }
            else
            {
                MetaHelper.SetMetaFieldValue(MetaField.Context, MetaObject, MetaField.Name, new object[] { null });
            }
        }
Example #3
0
 protected override object ConvertToDictionary(object value, MetaDataType DestType, string DestFieldName, int RowIndex, out MDPImportWarning[] warnings)
 {
     warnings = null;
     if (DestType == MetaDataType.StringDictionary)
     {
         MetaStringDictionary dic        = new MetaStringDictionary();
         JavaScriptSerializer serializer = new JavaScriptSerializer();
         object[]             col        = serializer.DeserializeObject((string)value) as object[];
         foreach (Dictionary <string, object> item in col)
         {
             dic.Add((string)item["Key"], (string)item["Value"]);
         }
         value = dic;
     }
     else if (DestType == MetaDataType.DictionaryMultiValue || DestType == MetaDataType.EnumMultiValue)
     {
         string[] values = value.ToString().Split(new char[] { ',' });
         value = new MetaDictionaryItem[values.Length];
         for (int i = 0; i < values.Length; i++)
         {
             ((MetaDictionaryItem[])value)[i] = findDictionaryItem(values[i].Trim(), DestFieldName);
             if (((MetaDictionaryItem[])value)[i] == null)
             {
                 throw new Mediachase.MetaDataPlus.Import.InvalidCastException(DestType.ToString(), value.GetType().ToString());
             }
         }
     }
     else
     {
         object val = findDictionaryItem(value.ToString().Trim(), DestFieldName);
         if (val == null)
         {
             throw new Mediachase.MetaDataPlus.Import.MDPImportException(String.Format("Invalid value '{0}' for dictionary '{1}'.", value, DestFieldName));
         }
         value = val;
     }
     return(value);
 }
Example #4
0
        /// <summary>
        /// Creates the attributes.
        /// </summary>
        /// <param name="metaAttributes">The meta attributes.</param>
        /// <param name="row">The row.</param>
        public static void CreateAttributes(ItemAttributes metaAttributes, DataRow row)
        {
            ArrayList attributes = new ArrayList();
            ArrayList files      = new ArrayList();
            ArrayList images     = new ArrayList();

            // Make sure we don't loose someone elses data
            if (metaAttributes != null && metaAttributes.Attribute != null)
            {
                foreach (ItemAttribute attr in metaAttributes.Attribute)
                {
                    attributes.Add(attr);
                }
            }

            // Make sure we don't loose someone elses data
            if (metaAttributes != null && metaAttributes.Files != null && metaAttributes.Files.File != null)
            {
                foreach (ItemFile file in metaAttributes.Files.File)
                {
                    files.Add(file);
                }
            }

            // Make sure we don't loose someone elses data
            if (metaAttributes != null && metaAttributes.Images != null)
            {
                //Changed this loop from a foreach to a for loop because metaAttributes.Image
                //was originally used but has been deprecated. metaAttributes.Images.Image
                //used instead
                for (int i = 0; i < metaAttributes.Images.Image.Length; i++)
                {
                    images.Add(metaAttributes.Images.Image[i]);
                }
            }


            // Get meta class id
            int metaClassId = (int)row["MetaClassId"];

            if (metaClassId == 0)
            {
                return;
            }



            // load list of MetaFields for MetaClass
            MetaClass metaClass = MetaHelper.LoadMetaClassCached(CatalogContext.MetaDataContext, metaClassId);

            if (metaClass == null)
            {
                return;
            }

            MetaFieldCollection mfs = metaClass.MetaFields;

            if (mfs == null)
            {
                return;
            }

            Hashtable hash = GetMetaFieldValues(row, metaClass, ref metaAttributes);

            /*
             * Hashtable hash = null;
             *
             * // try loading from serialized binary field first
             * if (row.Table.Columns.Contains(MetaObjectSerialized.SerializedFieldName) && row[MetaObjectSerialized.SerializedFieldName] != DBNull.Value)
             * {
             *  IFormatter formatter = null;
             *  try
             *  {
             *      formatter = new BinaryFormatter();
             *      MetaObjectSerialized metaObjSerialized = (MetaObjectSerialized)formatter.Deserialize(new MemoryStream((byte[])row[MetaObjectSerialized.SerializedFieldName]));
             *      if (metaObjSerialized != null)
             *      {
             *          metaAttributes.CreatedBy = metaObjSerialized.CreatorId;
             *          metaAttributes.CreatedDate = metaObjSerialized.Created;
             *          metaAttributes.ModifiedBy = metaObjSerialized.ModifierId;
             *          metaAttributes.ModifiedDate = metaObjSerialized.Modified;
             *          hash = metaObjSerialized.GetValues(CatalogContext.MetaDataContext.Language);
             *      }
             *  }
             *  finally
             *  {
             *      formatter = null;
             *  }
             * }
             *
             * // Load from database
             * if (hash == null)
             * {
             *  MetaObject metaObj = MetaObject.Load(CatalogContext.MetaDataContext, (int)row[0], metaClass);
             *  if (metaObj != null)
             *  {
             *      metaAttributes.CreatedBy = metaObj.CreatorId;
             *      metaAttributes.CreatedDate = metaObj.Created;
             *      metaAttributes.ModifiedBy = metaObj.ModifierId;
             *      metaAttributes.ModifiedDate = metaObj.Modified;
             *      hash = metaObj.GetValues();
             *  }
             * }
             * */

            if (hash == null)
            {
                return;
            }

            // fill in MetaField DataSet
            foreach (MetaField mf in mfs)
            {
                // skip system MetaFields
                if (!mf.IsUser)
                {
                    continue;
                }

                // get meta field's value
                object value = null;
                if (hash.ContainsKey(mf.Name))
                {
                    value = MetaHelper.GetMetaFieldValue(mf, hash[mf.Name]);
                }

                // create row in dataset for current meta field
                switch (mf.DataType)
                {
                case MetaDataType.File:
                    MetaFile metaFile = value as MetaFile;

                    if (metaFile != null)
                    {
                        ItemFile file = new ItemFile();
                        file.ContentType  = metaFile.ContentType;
                        file.FileContents = metaFile.Buffer;
                        file.FileName     = metaFile.Name;
                        file.Name         = mf.Name;
                        file.Type         = mf.DataType.ToString();
                        file.FriendlyName = mf.FriendlyName;

                        files.Add(file);
                    }
                    break;

                case MetaDataType.Image:
                case MetaDataType.ImageFile:

                    string fileName = String.Format("{0}-{1}-{2}", metaClassId, (int)row[0], mf.Name);

                    bool createThumbnail = false;
                    int  imageWidth      = 0;
                    int  imageHeight     = 0;
                    int  thumbWidth      = 0;
                    int  thumbHeight     = 0;
                    bool thumbStretch    = false;

                    object createThumbnaleObj = mf.Attributes["CreateThumbnail"];
                    if (createThumbnaleObj != null && Boolean.Parse(createThumbnaleObj.ToString()))
                    {
                        createThumbnail = true;

                        object var = mf.Attributes["AutoResize"];

                        if (var != null && Boolean.Parse(var.ToString()))
                        {
                            var = mf.Attributes["ImageHeight"];
                            if (var != null)
                            {
                                imageHeight = Int32.Parse(var.ToString());
                            }

                            var = mf.Attributes["ImageWidth"];
                            if (var != null)
                            {
                                imageHeight = Int32.Parse(var.ToString());
                            }
                        }

                        var = mf.Attributes["CreateThumbnail"];

                        if (var != null && Boolean.Parse(var.ToString()))
                        {
                            var = mf.Attributes["ThumbnailHeight"];
                            if (var != null)
                            {
                                thumbHeight = Int32.Parse(var.ToString());
                            }

                            var = mf.Attributes["ThumbnailWidth"];
                            if (var != null)
                            {
                                thumbWidth = Int32.Parse(var.ToString());
                            }

                            var = mf.Attributes["StretchThumbnail"];
                            if (var != null && Boolean.Parse(var.ToString()))
                            {
                                thumbStretch = true;
                            }
                        }
                    }

                    //string[] val = MetaHelper.GetCachedImageUrl((MetaFile)hash[mf.Name], mf, fileName, createThumbnail, thumbHeight, thumbWidth, thumbStretch);

                    string imageUrl      = ImageService.RetrieveImageUrl(fileName);
                    string imageThumbUrl = ImageService.RetrieveThumbnailImageUrl(fileName);

                    //if (val != null)
                    {
                        Image attr = CreateImage(mf.Name, imageUrl);

                        if (createThumbnail)
                        {
                            attr.ThumbnailUrl = imageThumbUrl;
                        }

                        if (imageHeight != 0)
                        {
                            attr.Height = imageHeight.ToString();
                        }

                        if (imageWidth != 0)
                        {
                            attr.Width = imageWidth.ToString();
                        }

                        if (thumbHeight != 0)
                        {
                            attr.ThumbnailHeight = thumbHeight.ToString();
                        }

                        if (thumbWidth != 0)
                        {
                            attr.ThumbnailWidth = thumbWidth.ToString();
                        }

                        images.Add(attr);
                    }
                    break;

                case MetaDataType.BigInt:
                case MetaDataType.Bit:
                case MetaDataType.Boolean:
                case MetaDataType.Char:
                case MetaDataType.Date:
                case MetaDataType.DateTime:
                case MetaDataType.Decimal:
                case MetaDataType.Email:
                case MetaDataType.Float:
                case MetaDataType.Int:
                case MetaDataType.Integer:
                case MetaDataType.LongHtmlString:
                case MetaDataType.LongString:
                case MetaDataType.Money:
                case MetaDataType.NChar:
                case MetaDataType.NText:
                case MetaDataType.Numeric:
                case MetaDataType.NVarChar:
                case MetaDataType.Real:
                case MetaDataType.ShortString:
                case MetaDataType.SmallDateTime:
                case MetaDataType.SmallInt:
                case MetaDataType.SmallMoney:
                case MetaDataType.Sysname:
                case MetaDataType.Text:
                case MetaDataType.Timestamp:
                case MetaDataType.TinyInt:
                case MetaDataType.UniqueIdentifier:
                case MetaDataType.URL:
                case MetaDataType.VarChar:
                case MetaDataType.Variant:
                case MetaDataType.DictionarySingleValue:
                case MetaDataType.EnumSingleValue:
                    attributes.Add(ObjectHelper.CreateAttribute(mf.Name, mf.FriendlyName, mf.DataType.ToString(), new string[] { value == null ? String.Empty : value.ToString() }));
                    break;

                case MetaDataType.EnumMultiValue:
                case MetaDataType.DictionaryMultiValue:
                    attributes.Add(ObjectHelper.CreateAttribute(mf.Name, mf.FriendlyName, "string[]", (string[])value));
                    break;

                case MetaDataType.StringDictionary:
                    MetaStringDictionary stringDictionary = value as MetaStringDictionary;
                    ArrayList            strvals          = new ArrayList();
                    if (stringDictionary != null)
                    {
                        foreach (string key in stringDictionary.Keys)
                        {
                            strvals.Add(String.Format("{0};{1}", key, stringDictionary[key]));
                        }
                    }
                    attributes.Add(ObjectHelper.CreateAttribute(mf.Name, mf.FriendlyName, "string[]", stringDictionary == null ? null : (string[])strvals.ToArray(typeof(string))));
                    break;

                default:
                    break;
                }
            }

            metaAttributes.Attribute    = (ItemAttribute[])attributes.ToArray(typeof(ItemAttribute));
            metaAttributes.Files        = new ItemFiles();
            metaAttributes.Files.File   = (ItemFile[])files.ToArray(typeof(ItemFile));
            metaAttributes.Images       = new Images();
            metaAttributes.Images.Image = (Image[])images.ToArray(typeof(Image));
        }
Example #5
0
        /// <summary>
        /// Adds the field.
        /// </summary>
        /// <param name="doc">The doc.</param>
        /// <param name="metaField">The meta field.</param>
        /// <param name="metaObject">The meta object.</param>
        protected virtual void AddField(Document doc, MetaField metaField, Hashtable metaObject)
        {
            if (metaField.AllowSearch)
            {
                Field.Store store = null;
                Field.Index index = null;
                if (metaField.Attributes["IndexStored"] != null)
                {
                    if (metaField.Attributes["IndexStored"].Equals("true", StringComparison.OrdinalIgnoreCase))
                    {
                        store = Field.Store.YES;
                    }
                    else
                    {
                        store = Field.Store.NO;
                    }
                }

                if (metaField.Attributes["IndexField"] != null)
                {
                    if (metaField.Attributes["IndexField"].Equals("tokenized", StringComparison.OrdinalIgnoreCase))
                    {
                        index = Field.Index.TOKENIZED;
                    }
                    else
                    {
                        index = Field.Index.UN_TOKENIZED;
                    }
                }

                object val = MetaHelper.GetMetaFieldValue(metaField, metaObject[metaField.Name]);
                //object val = metaObject[metaField];
                string valString = String.Empty;
                if (
                    metaField.DataType == MetaDataType.BigInt ||
                    metaField.DataType == MetaDataType.Decimal ||
                    metaField.DataType == MetaDataType.Float ||
                    metaField.DataType == MetaDataType.Int ||
                    metaField.DataType == MetaDataType.Money ||
                    metaField.DataType == MetaDataType.Numeric ||
                    metaField.DataType == MetaDataType.SmallInt ||
                    metaField.DataType == MetaDataType.SmallMoney ||
                    metaField.DataType == MetaDataType.TinyInt
                    )
                {
                    if (val != null)
                    {
                        valString = val.ToString();
                        if (!String.IsNullOrEmpty(valString))
                        {
                            if (metaField.DataType == MetaDataType.Decimal)
                            {
                                doc.Add(new Field(metaField.Name, ConvertStringToSortable(Decimal.Parse(valString)), store == null ? Field.Store.NO : store, index == null ? Field.Index.UN_TOKENIZED : index));
                            }
                            else
                            {
                                doc.Add(new Field(metaField.Name, ConvertStringToSortable(valString), store == null ? Field.Store.NO : store, index == null ? Field.Index.UN_TOKENIZED : index));
                            }
                        }
                    }
                }
                else if (val != null)
                {
                    if (metaField.DataType == MetaDataType.DictionaryMultiValue)
                    {
                        foreach (string s in (string[])val)
                        {
                            doc.Add(new Field(metaField.Name, s == null ? String.Empty : s.ToLower(), store == null ? Field.Store.NO : store, index == null ? Field.Index.TOKENIZED : index));
                            doc.Add(new Field("_content", s == null ? String.Empty : s.ToString().ToLower(), store == null ? Field.Store.NO : store, index == null ? Field.Index.TOKENIZED : index));
                        }
                    }
                    else if (metaField.DataType == MetaDataType.StringDictionary)
                    {
                        MetaStringDictionary stringDictionary = val as MetaStringDictionary;
                        ArrayList            strvals          = new ArrayList();
                        if (stringDictionary != null)
                        {
                            foreach (string key in stringDictionary.Keys)
                            {
                                string s = stringDictionary[key];
                                doc.Add(new Field(metaField.Name, s == null ? String.Empty : s.ToLower(), store == null ? Field.Store.NO : store, index == null ? Field.Index.TOKENIZED : index));
                                doc.Add(new Field("_content", s == null ? String.Empty : s.ToString().ToLower(), store == null ? Field.Store.NO : store, index == null ? Field.Index.TOKENIZED : index));
                            }
                        }
                    }
                    else
                    {
                        doc.Add(new Field(metaField.Name, val == null ? String.Empty : val.ToString().ToLower(), store == null ? Field.Store.NO : store, index == null ? Field.Index.TOKENIZED : index));
                        doc.Add(new Field("_content", val == null ? String.Empty : val.ToString().ToLower(), store == null ? Field.Store.NO : store, index == null ? Field.Index.TOKENIZED : index));
                    }
                }
            }
        }
Example #6
0
        /// <summary>
        /// Sets values for the meta object's meta field. Doesn't set file and image values.
        /// </summary>
        /// <param name="context">The context.</param>
        /// <param name="obj">The obj.</param>
        /// <param name="fieldName">Name of the field.</param>
        /// <param name="values">The values.</param>
        /// <returns>True, if value was set successfully.</returns>
        public static bool SetMetaFieldValue(MetaDataContext context, MetaObject obj, string fieldName, object[] values)
        {
            MetaField mf = MetaField.Load(context, fieldName);

            if (mf == null)
            {
                return(false);
            }

            // assign default meta field value if value is not specified and meta field doesn't allow null values
            if (values == null || values.Length == 0)
            {
                obj[mf.Name] = mf.AllowNulls ? null : MetaObject.GetDefaultValue(mf.DataType);
                return(true);
            }

            // assign the value depending on meta field's type
            switch (mf.DataType)
            {
            case MetaDataType.File:
                // do not assign file values in this function
                throw new ApplicationException("do not assign file values in this function");

            case MetaDataType.Image:
            case MetaDataType.ImageFile:
                // do not assign image values in this function
                throw new ApplicationException("do not assign file values in this function");

            case MetaDataType.BigInt:
            case MetaDataType.Bit:
            case MetaDataType.Boolean:
            case MetaDataType.Char:
            case MetaDataType.Date:
            case MetaDataType.DateTime:
            case MetaDataType.Decimal:
            case MetaDataType.Email:
            case MetaDataType.Float:
            case MetaDataType.Int:
            case MetaDataType.Integer:
            case MetaDataType.LongHtmlString:
            case MetaDataType.LongString:
            case MetaDataType.Money:
            case MetaDataType.NChar:
            case MetaDataType.NText:
            case MetaDataType.Numeric:
            case MetaDataType.NVarChar:
            case MetaDataType.Real:
            case MetaDataType.ShortString:
            case MetaDataType.SmallDateTime:
            case MetaDataType.SmallInt:
            case MetaDataType.SmallMoney:
            case MetaDataType.Sysname:
            case MetaDataType.Text:
            case MetaDataType.Timestamp:
            case MetaDataType.TinyInt:
            case MetaDataType.UniqueIdentifier:
            case MetaDataType.URL:
            case MetaDataType.VarChar:
            case MetaDataType.Variant:
                obj[mf.Name] = values[0];
                break;

            case MetaDataType.DictionarySingleValue:
            case MetaDataType.EnumSingleValue:
                // find a dictionary if type is string
                if (values[0] == null || values[0].GetType() == typeof(MetaDictionaryItem))
                {
                    obj[mf.Name] = values[0];
                    break;
                }
                else
                {
                    string value = values[0].ToString();
                    foreach (MetaDictionaryItem dic in mf.Dictionary)
                    {
                        if (String.Compare(dic.Value, value, true) == 0)
                        {
                            obj[mf.Name] = dic;
                            break;
                        }
                    }
                }
                break;

            case MetaDataType.EnumMultiValue:
            case MetaDataType.DictionaryMultiValue:
                ArrayList dics = new ArrayList();
                foreach (string val1 in values)
                {
                    int valueInt = 0;
                    Int32.TryParse(val1.ToString(), out valueInt);
                    foreach (MetaDictionaryItem dic in mf.Dictionary)
                    {
                        if (dic.Id == Int32.Parse(val1))
                        {
                            dics.Add(dic);
                            break;
                        }
                    }
                }
                obj[mf.Name] = (MetaDictionaryItem[])dics.ToArray(typeof(MetaDictionaryItem));
                break;

            case MetaDataType.StringDictionary:
                // if meta field type is StringDictionary, then values must be one of the following:
                // 1. values[0] is MetaStringDictionary
                // 2. values is array of string dictionary values where each values[i] is a combination of key and value divided by semicolon, i.e. value[i]="key;value"
                if (values[0] == null || values[0].GetType() == typeof(MetaStringDictionary))
                {
                    obj[mf.Name] = values[0];
                    break;
                }
                else
                {
                    MetaStringDictionary strDict = new MetaStringDictionary();
                    foreach (string row in (string[])values)
                    {
                        string[] val = row.Split(';');
                        if (val.Length >= 2)
                        {
                            strDict.Add(val[0], val[1]);
                        }
                    }
                    obj[mf.Name] = strDict;
                }
                break;

            default:
                break;
            }

            return(true);
        }
Example #7
0
        void LoadMetaFields2()
        {
            foreach (MetaField field in this.MetaClass.MetaFields)
            {
                if (field.IsSystem)
                    continue;

                object FieldValue = this[field.Name];

                if (FieldValue != null)
                {
                    if (field.DataType == MetaDataType.DictionarySingleValue ||
                        field.DataType == MetaDataType.EnumSingleValue)
                    {
                        //bool bFound = false;
                        //foreach (MetaDictionaryItem DicItem in field.Dictionary)
                        //{
                        //    if (DicItem.Id == (int)FieldValue)
                        //    {
                        //        bFound = true;
                        //        FieldValue = DicItem;
                        //        break;
                        //    }
                        //}

                        //if (!bFound)
                        //{
                        //    System.Diagnostics.Trace.WriteLine(string.Format("Couldn't find the MetaDictionaryItem (Id = {0}).", (int)FieldValue), "Mediachase.MetaDataPlus.MetaObject");
                        //    FieldValue = null;
                        //}
                    }
                    else if (field.DataType == MetaDataType.DictionaryMultivalue ||
                        field.DataType == MetaDataType.EnumMultivalue)
                    {
                        int MetaKey = (int)FieldValue;

                        // TODO: Move it in to the current transaction [12/1/2004]
                        using (SqlDataReader readerValue = SqlHelper.ExecuteReader(MetaDataContext.Current, CommandType.StoredProcedure, AsyncResources.GetConstantValue("SP_LoadMultivalueDictionary"),
                                  new SqlParameter("@MetaKey", MetaKey)))
                        {
                            ArrayList MultuValues = new ArrayList();

                            while (readerValue.Read())
                            {
                                foreach (MetaDictionaryItem DicItem in field.Dictionary)
                                {
                                    if (DicItem.Id == (int)readerValue["MetaDictionaryId"])
                                    {
                                        MultuValues.Add(DicItem);
                                        break;
                                    }
                                }
                            }
                            readerValue.Close();

                            FieldValue = (MetaDictionaryItem[])MultuValues.ToArray(typeof(MetaDictionaryItem));
                        }
                    }
                    else if (field.DataType == MetaDataType.File || field.DataType == MetaDataType.ImageFile)
                    {
                        int MetaKey = (int)FieldValue;

                        // TODO: Move it in to the current transaction [12/1/2004]
                        using (SqlDataReader readerValue = SqlHelper.ExecuteReader(MetaDataContext.Current, CommandType.StoredProcedure, AsyncResources.GetConstantValue("SP_LoadMetaFile"),
                                  new SqlParameter("@MetaKey", MetaKey)))
                        {
                            if (readerValue.Read())
                            {
                                MetaFile file = new MetaFile(readerValue);

                                FieldValue = file;
                            }
                            else
                                FieldValue = null;

                            readerValue.Close();
                        }

                    }
                    else if (field.DataType == MetaDataType.StringDictionary)
                    {
                        int MetaKey = (int)FieldValue;

                        // TODO: Move it in to the current transaction [12/1/2004]
                        using (SqlDataReader readerValue = SqlHelper.ExecuteReader(MetaDataContext.Current, CommandType.StoredProcedure, AsyncResources.GetConstantValue("SP_LoadMetaStringDictionary"),
                                  new SqlParameter("@MetaKey", MetaKey)))
                        {
                            if (readerValue.Read())
                            {
                                MetaStringDictionary dic = new MetaStringDictionary();
                                dic.LoadDictionary(readerValue);
                                FieldValue = dic;
                            }
                            else
                                FieldValue = null;

                            readerValue.Close();
                        }
                    }
                    else if (field.DataType == MetaDataType.MetaObject)
                    {
                        using (SqlDataReader readerValue = SqlHelper.ExecuteReader(MetaDataContext.Current, CommandType.StoredProcedure, AsyncResources.GetConstantValue("SP_LoadMetaObjectValue"),
                                  new SqlParameter("@MetaKey", (int)FieldValue)))
                        {
                            int MetaClassId = -1;
                            int MetaObjectId = -1;

                            if (readerValue.Read())
                            {
                                MetaClassId = (int)readerValue["MetaClassId"];
                                MetaObjectId = (int)readerValue["MetaObjectId"];

                                readerValue.Close();

                                try
                                {
                                    FieldValue = MetaObject.Load(MetaObjectId, MetaClassId);
                                }
                                catch (Exception ex)
                                {
                                    FieldValue = null;
                                    System.Diagnostics.Trace.WriteLine(ex, "Load MetaDataType.MetaObject");
                                }
                            }
                            else
                            {
                                FieldValue = null;
                                readerValue.Close();
                            }
                        }

                    }
                }

                _fieldStorage[field.Name] = FieldValue;
            }

            this._state = MetaObjectState.Unchanged;
        }