public ColumnDTO GetColumn(int columnID, bool simple)
        {
            ColumnDTO result = new ColumnDTO();

            using (var projectContext = new MyIdeaEntities())
            {
                var column = projectContext.Column.First(x => x.ID == columnID);
                return(ToColumnDTO(column, simple));
            }
        }
        public List <DateColumnTypeDTO> GetDateColumType(int columnID)
        {
            ColumnDTO result = new ColumnDTO();

            using (var projectContext = new MyIdeaEntities())
            {
                var column = projectContext.Column.First(x => x.ID == columnID);
                if (column.DateColumnType != null)
                {
                    return(GeneralHelper.CreateListFromSingleObject <DateColumnTypeDTO>(ToDateColumTypeDTO(column.DateColumnType)));
                }
            }
            return(null);
        }
        public ColumnDTO ToColumnDTO(Column item, bool simple)
        {
            //var cachedItem = CacheManager.GetCacheManager().GetCachedItem(CacheItemType.Column, item.ID.ToString(), simple.ToString());
            //if (cachedItem != null)
            //    return (cachedItem as ColumnDTO);

            ColumnDTO result = new ColumnDTO();

            result.Name       = item.Name;
            result.DataType   = item.DataType;
            result.ID         = item.ID;
            result.TableID    = item.TableID;
            result.IsNull     = item.IsNull;
            result.PrimaryKey = item.PrimaryKey;
            if (item.TypeEnum != null)
            {
                result.ColumnType = (Enum_ColumnType)item.TypeEnum;
            }
            else
            {
                result.ColumnType = Enum_ColumnType.None;
            }

            if (!string.IsNullOrEmpty(item.Alias))
            {
                result.Alias = item.Alias;
            }
            else
            {
                result.Alias = item.Name;
            }
            result.DataEntryEnabled     = item.DataEntryEnabled;
            result.DefaultValue         = item.DefaultValue;
            result.IsMandatory          = item.IsMandatory;
            result.IsIdentity           = item.IsIdentity;
            result.IsDBCalculatedColumn = item.IsDBCalculatedColumn;
            result.Position             = (item.Position == null ? 0 : item.Position.Value);
            result.SearchEnabled        = item.SearchEnabled == true;
            //result.ViewEnabled = item.ViewEnabled == true;
            result.DataEntryView = item.DataEntryView;
            result.DotNetType    = GetColumnDotNetType(result.DataType);
            if (!simple)
            {
                if (item.StringColumnType != null)
                {
                    result.StringColumnType = ToStringColumTypeDTO(item.StringColumnType);
                }
                if (item.NumericColumnType != null)
                {
                    result.NumericColumnType = ToNumericColumTypeDTO(item.NumericColumnType);
                }
                if (item.DateColumnType != null)
                {
                    result.DateColumnType = ToDateColumTypeDTO(item.DateColumnType);
                }

                if (item.ColumnKeyValue != null)
                {
                    result.ColumnKeyValue = ToColumnKeyValueDTO(item.ColumnKeyValue);
                }
                //    if (item.DBCalculatedColumn != null)
                //        result.DBFormula = item.DBCalculatedColumn.Formula;

                //    if (item.CustomCalculatedColumn != null)
                //        result.CustomFormula = new BizFormula().ToFormulaDTO(item.CustomCalculatedColumn.Formula,false);
                //}
            }
            //CacheManager.GetCacheManager().AddCacheItem(result, CacheItemType.Column, item.ID.ToString(), simple.ToString());
            return(result);
        }
 public Type GetColumnDotNetType(ColumnDTO column)
 {
     return(GetColumnDotNetType(column.DataType));
 }