예제 #1
0
        private void ConstructParameter()
        {
            var    type = ProperVBTypeName.Get(datacolumn);
            string name = ProperVarName.Get(datacolumn.ColumnName.ToLower());

            this.MethodArgs.Add(new VBArgument(type, name));
        }
예제 #2
0
        private void ConstructParameter()
        {
            foreach (DataColumn clm in this.datatable.PrimaryKey)
            {
                var    type = ProperVBTypeName.Get(clm);
                string name = clm.ColumnName.ToLower();

                this.MethodArgs.Add(new VBArgument(type, name));
            }
        }
예제 #3
0
        private void CreateProperties(DataTable dataTable)
        {
            VBProperty        property;
            List <VBProperty> properties = new List <VBProperty>();

            foreach (DataColumn clm in dataTable.Columns)
            {
                string typeName = ProperVBTypeName.Get(clm);
                string name     = ProperVarName.Get(clm.ColumnName);

                property = new VBProperty(typeName, name, VBMemberModifier.PublicOverridable);
                properties.Add(property);
            }
            this.Properties = properties;
        }
예제 #4
0
        private void ConstructBody()
        {
            string className    = datatable.TableName;
            string instanceName = ProperVarName.Get(datatable.TableName.ToLower());

            this.Statements.Add("Dim dt As DataTable = table.DbAccess.GetDataTable(sqlCommand)");
            this.Statements.Add($"Dim list As List(Of {className}) = New List(Of {className})()");

            VBBlock forEachBlock = new VBBlock(VBBlockStatement.ForEach, "For Each dataRow As DataRow In dt.Rows");

            forEachBlock.Statements.Add($"Dim {instanceName} As {className} = New {className}()");

            foreach (DataColumn clm in datatable.Columns)
            {
                string clmName  = ProperVarName.Get(clm.ColumnName, false);
                string propName = ProperVarName.Get(clm.ColumnName, true);
                if (clm.AllowDBNull)
                {
                    forEachBlock.Statements.Add($"{instanceName}.{propName} = CType(If(dataRow({Quotes}{clmName}{Quotes}) Is DBNull.Value, Nothing, dataRow({Quotes}{clmName}{Quotes})), {ProperVBTypeName.Get(clm)})");
                }
                else
                {
                    forEachBlock.Statements.Add($"{instanceName}.{propName} = CType(dataRow({Quotes}{clmName}{Quotes}), {ProperVBTypeName.Get(clm)})");
                }
            }
            forEachBlock.Statements.Add($"list.Add({instanceName})");
            this.Statements.Add(forEachBlock.ToString());
            this.Statements.Add("Return list");
        }