コード例 #1
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);
        }
コード例 #2
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);
        }
コード例 #3
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);
        }
コード例 #4
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;
            }
        }