Ejemplo n.º 1
0
        /// <summary>
        /// Safe Type Name
        /// <remarks>Retrurns the safe Type Name</remarks>
        /// </summary>
        /// <returns></returns>
        public String TypeName()
        {
            Type   NetType      = TypeConvertor.ToBasicNetType(this.SqlColumn.DataType.SqlDataType);
            String SafeTypeName = NetType.Name;

            if (NetType == typeof(Boolean))
            {
                SafeTypeName = "bool?";
            }

            if (NetType == typeof(Decimal))
            {
                SafeTypeName = "Nullable<Decimal>";
            }

            if (NetType == typeof(Int32))
            {
                SafeTypeName = "int?";
            }

            if (NetType == typeof(Int64))
            {
                SafeTypeName = "long?";
            }

            if (NetType == typeof(DateTime))
            {
                SafeTypeName = "DateTime?";
            }

            return(SafeTypeName);
        }
Ejemplo n.º 2
0
        public CodeParameterDeclarationExpression GetParameter()
        {
            CodeParameterDeclarationExpression cpde = new CodeParameterDeclarationExpression();

            cpde.Direction = FieldDirection.In;
            cpde.Name      = this.ParameterName();
            cpde.Type      = new CodeTypeReference(TypeConvertor.ToNetType(this.SqlColumn.DataType.SqlDataType));

            return(cpde);
        }
Ejemplo n.º 3
0
        public CodeMemberField GetField()
        {
            CodeMemberField cmf = new CodeMemberField();

            // Version 2 TODO: Add Custom Attributes based on Data column
            //                 Add ASP.NET UI Element Attributes
            cmf.Name       = this.FieldName();
            cmf.Attributes = MemberAttributes.Private;
            cmf.Type       = new CodeTypeReference(TypeConvertor.ToNetType(this.SqlColumn.DataType.SqlDataType));
            cmf.Type       = new CodeTypeReference(this.GraphType);

            return(cmf);
        }
Ejemplo n.º 4
0
        public static IEnumerable <Type> NullabeTypes()
        {
            List <Type> NTypes = new List <Type>();

            NTypes.Add(typeof(System.Boolean));
            NTypes.Add(typeof(System.Decimal));
            NTypes.Add(typeof(bool));

            foreach (Type t in TypeConvertor.NumericTypes())
            {
                NTypes.Add(t);
            }

            return(NTypes);
        }
Ejemplo n.º 5
0
        /// <summary>
        /// Builds List of Code Statmenets that converts a Type into a DAL Parameter Statement
        /// </summary>
        /// <param name="table"></param>
        /// <returns></returns>
        public static CodeStatementCollection BuildAttributeSetStatement(TableViewTableTypeBase table)
        {
            CodeStatementCollection AttributeSetStatement = new CodeStatementCollection();
            String PocoTypeName     = table.Name;
            String FullPocoTypeName = PocoTypeName;

            foreach (Column c in table.Columns)
            {
                MemberGraph mGraph = new MemberGraph(c);
                if (mGraph.IsReadOnly)
                {
                    // nothing yet
                }
                else
                {
                    String DotNetTypeName = TypeConvertor.ToNetType(c.DataType.SqlDataType).ToString();

                    System.CodeDom.CodeConditionStatement ccsField = new CodeConditionStatement();
                    if (mGraph.IsNullable)
                    {
                        ccsField.Condition = new CodeSnippetExpression("query." + mGraph.PropertyName() + ".HasValue");
                        ccsField.TrueStatements.Add(new CodeSnippetExpression("this.Access.AddParameter(\"" + mGraph.PropertyName() + "\",query." + mGraph.PropertyName() + ".Value, ParameterDirection.Input)"));
                        ccsField.FalseStatements.Add(new CodeSnippetExpression("this.Access.AddParameter(\"" + mGraph.PropertyName() + "\", null , ParameterDirection.Input)"));
                    }
                    else
                    {
                        ccsField.Condition = new CodeSnippetExpression("query." + mGraph.PropertyName() + " == null");
                        ccsField.TrueStatements.Add(new CodeSnippetExpression("this.Access.AddParameter(\"" + mGraph.PropertyName() + "\", null , ParameterDirection.Input)"));
                        ccsField.FalseStatements.Add(new CodeSnippetExpression("this.Access.AddParameter(\"" + mGraph.PropertyName() + "\",query." + mGraph.PropertyName() + ", ParameterDirection.Input)"));
                    }

                    AttributeSetStatement.Add(ccsField);
                }
            }

            return(AttributeSetStatement);
        }
Ejemplo n.º 6
0
        public MemberGraph(Column sqlColumn)
        {
            this.SqlColumn  = sqlColumn;
            this.Name       = SqlColumn.Name;
            this.GraphType  = TypeConvertor.ToNetType(sqlColumn.DataType.SqlDataType);
            this.IsReadOnly = false;

            if (sqlColumn.Computed)
            {
                this.IsReadOnly = true;
            }

            if (sqlColumn.Parent.IsView())
            {
                this.IsReadOnly = true;
            }


            if (TypeConvertor.NullabeTypes().Contains(this.GraphType))
            {
                this.IsNullable = true;
            }
            else
            {
                this.IsNullable = false;
            }

            if (this.SqlColumn.Nullable)
            {
                this.Required = false;
            }
            else
            {
                this.Required = true;
            }
        }