public override bool Equals(object obj)
        {
            if (obj is string)
            {
                return(obj == Name);
            }

            else if (obj is BusinessObjectStructure)
            {
                BusinessObjectStructure tmpObj = obj as BusinessObjectStructure;
                return(tmpObj.Name == Name);
            }
            else
            {
                return(base.Equals(obj));
            }
        }
        public static object ReadObjectValue(IGenericBusinessObj obj, string name, ObjectStateEntry currentEntry)
        {
            List <BusinessObjectStructure> tableFields = obj.GetTableFields(currentEntry);

            Adage.EF.Interfaces.BusinessObjectStructure fieldToGet = tableFields.Where(c => c.Name == name).FirstOrDefault();

            if (fieldToGet == null)
            {
                throw new ApplicationException("Could not find the property:" + name);
            }

            if (fieldToGet.IsCSpaceColumn)
            {
                return(currentEntry.CurrentValues.GetValue(fieldToGet.CSpaceIndex.Value));
            }
            else
            {
                return(fieldToGet.PropertyInfo.GetValue(obj, null));
            }
        }
        /// <summary>
        /// This method adds the fields only if they do not already exist in the array
        /// </summary>
        /// <param name="_tableFields"></param>
        /// <param name="propInfo"></param>
        private static void AddDataObjectFieldProperties(List <Adage.EF.Interfaces.BusinessObjectStructure> _tableFields, System.Reflection.PropertyInfo propInfo)
        {
            Adage.EF.Interfaces.BusinessObjectStructure    currStruct;
            System.ComponentModel.DataObjectFieldAttribute dataPropInfo;

            if (propInfo.IsDefined(dataPropType, true))
            {
                bool alreadyContainsProperty = false;
                _tableFields.ForEach(p =>
                                     alreadyContainsProperty = p.Name == propInfo.Name
                    ? true : alreadyContainsProperty);

                if (!alreadyContainsProperty)
                {
                    dataPropInfo = (System.ComponentModel.DataObjectFieldAttribute)Attribute.GetCustomAttribute(propInfo, dataPropType);
                    currStruct   = new Adage.EF.Interfaces.BusinessObjectStructure(
                        propInfo.PropertyType, propInfo.Name, dataPropInfo.IsNullable,
                        dataPropInfo.Length, false, null, propInfo);

                    _tableFields.Add(currStruct);
                }
            }
        }
        /// <summary>
        /// This method adds the fields only if they do not already exist in the array
        /// </summary>
        /// <param name="_tableFields"></param>
        /// <param name="propInfo"></param>
        private static void AddDataObjectFieldProperties(List<Adage.EF.Interfaces.BusinessObjectStructure> _tableFields, System.Reflection.PropertyInfo propInfo)
        {
            Adage.EF.Interfaces.BusinessObjectStructure currStruct;
            System.ComponentModel.DataObjectFieldAttribute dataPropInfo;

            if (propInfo.IsDefined(dataPropType, true))
            {
                bool alreadyContainsProperty = false;
                _tableFields.ForEach(p =>
                    alreadyContainsProperty = p.Name == propInfo.Name
                    ? true : alreadyContainsProperty);

                if (!alreadyContainsProperty)
                {
                    dataPropInfo = (System.ComponentModel.DataObjectFieldAttribute)Attribute.GetCustomAttribute(propInfo, dataPropType);
                    currStruct = new Adage.EF.Interfaces.BusinessObjectStructure(
                        propInfo.PropertyType, propInfo.Name, dataPropInfo.IsNullable,
                        dataPropInfo.Length, false, null, propInfo);

                    _tableFields.Add(currStruct);
                }
            }
        }
        public static object GetValidColumnValue(object input,
                                                 BusinessObjectStructure dc)
        {
            Type datatype   = Type.GetType(dc.DataType.FullName);
            bool isNullable = dc.IsNullable;

            if (IsNullableType(datatype))
            {
                datatype   = System.Nullable.GetUnderlyingType(datatype);
                isNullable = true;
            }

            if (datatype != typeof(System.String))
            {
                if ((input == null) || (input.ToString() == ""))
                {
                    if (dc.IsNullable)
                    {
                        return(null);
                    }
                    else
                    {
                        return(null);
                    }
                }
                else
                {
                    try
                    {
                        if (datatype.Equals(typeof(decimal)))
                        {
                            return(System.Decimal.Parse(input.ToString(), System.Globalization.NumberStyles.Currency));
                        }

                        if (datatype.Equals(typeof(System.Guid)))
                        {
                            return(new Guid(input.ToString()));
                        }

                        return(System.Convert.ChangeType(input, datatype));
                    }
                    catch (Exception)
                    {
                        if (dc.IsNullable)
                        {
                            return(null);
                        }
                        else
                        {
                            throw new ArgumentOutOfRangeException(dc.Name, input.ToString(),
                                                                  "The datatype conversion to " + datatype.ToString() + " failed from the value:" + input.ToString());
                        }
                    }
                }
            }
            else
            {
                if (input == null)
                {
                    if (dc.IsNullable)
                    {
                        return(null);
                    }
                    else
                    {
                        return(string.Empty);
                    }
                }
                else
                {
                    return(input.ToString());
                }
            }
        }