Exemplo n.º 1
0
        internal void GenerateSql(CSourceWriter sw)
        {
            sw.WriteLn("create table dbo." + this.Name + "(");
            bool primero = true;

            sw.AddTab();
            foreach (CFieldM f in this.lFieldAll)
            {
                f.GeneraSql(sw, ref primero);
            }
            if (this.lFieldPk.Count > 0)
            {
                sw.WriteLn(",CONSTRAINT PK_" + this.Name + " PRIMARY KEY (");
                primero = true;
                sw.AddTab();
                foreach (CFieldM f in this.lFieldPk)
                {
                    sw.Write("");
                    sw.WriteComma(ref primero);
                    sw.WriteLn(f.Name);
                }
                sw.DelTab();
                sw.WriteLn(")");
            }
            foreach (CUniqueConstraintM u in this.LUniqueConstraint)
            {
                u.GeneraSql(sw);
            }
            sw.DelTab();
            sw.WriteLn(")");

            sw.EndLine();
            sw.WriteLn("GO");
            //Genera las unique constraints
        }
        public override void Generate(CSourceWriter sw)
        {
            CSharpProject.WriteVisibility(sw, this.Visibility);
            sw.Space();
            if (this.IsStatic)
            {
                sw.Write("static");
                sw.Space();
            }
            if (this.IsOverride)
            {
                sw.Write("override");
                sw.Space();
            }
            this.Type.Generate(sw);
            sw.Space();
            sw.Write(this.Name);
            sw.Write("(");
            bool Primero = true;

            foreach (CParam p in this.lParam)
            {
                sw.WriteComma(ref Primero);
                p.Generate(sw);
            }
            sw.Write(")");
            sw.WriteLn("{");
            sw.AddTab();
            foreach (CSentence sen in lSentence)
            {
                sen.Generate(sw);
            }
            sw.DelTab();
            sw.WriteLn("}");
        }
        public override void Generate(CSourceWriter sw)
        {
            CSharpProject.WriteVisibility(sw, this.Visibility);
            sw.Space();
            if (this.Class == null)
            {
                throw new NullReferenceException("El constructor ha de tener una clase.");
            }
            sw.Write(this.Class.Name);
            sw.Write("(");
            bool Primero = true;

            foreach (CParam p in this.lParam)
            {
                sw.WriteComma(ref Primero);
                p.Generate(sw);
            }
            sw.Write(")");
            sw.OpenBracesLn();
            sw.AddTab();
            foreach (CSentence sen in lSentence)
            {
                sen.Generate(sw);
            }
            sw.DelTab();
            sw.CloseBracesLn();
        }
Exemplo n.º 4
0
        private void ParametrosCamposNoClavePorComas(CSourceWriter sw)
        {
            bool Primero = true;

            foreach (CFieldM f in this.lFieldData)
            {
                sw.WriteComma(ref Primero);
                sw.Write(SUtilBD.Param(f.Name));
            }
        }
Exemplo n.º 5
0
        private void CamposPorComas(CSourceWriter sw)
        {
            bool Primero = true;

            foreach (CFieldM f in this.lFieldAll)
            {
                sw.WriteComma(ref Primero);
                sw.Write(f.Name);
            }
        }
Exemplo n.º 6
0
        public void GeneraInsertMethod(CSourceWriter sw)
        {
            sw.Write("public static int Insert");
            sw.Write(this.Name);
            sw.Write("(");
            bool primero = true;

            foreach (CFieldM f in this.lFieldAll)
            {
                if (!f.IsIdentity)
                {
                    sw.WriteComma(ref primero);
                    sw.Write(f.csDataTypeName());
                    sw.Write(" ");
                    sw.Write(f.Name);
                }
            }
            sw.WriteComma(ref primero);
            sw.Write("SqlConnection con");
            sw.Write(")");
            sw.WriteLn("{");
        }
Exemplo n.º 7
0
        private void ParametrosCamposNoIdPorComas(CSourceWriter sw)
        {
            bool Primero = true;

            foreach (CFieldM f in this.lFieldAll)
            {
                if (!f.IsIdentity)
                {
                    sw.WriteComma(ref Primero);
                    sw.Write(SUtilBD.Param(f.Name));
                }
            }
        }
Exemplo n.º 8
0
        private void GeneraUpdate(CSourceWriter sw)
        {
            sw.Write("update ");
            sw.Write(this.Name);
            sw.Write(" set ");
            bool Primero = true;

            foreach (CFieldM f in this.lFieldData)
            {
                sw.WriteComma(ref Primero);
                sw.Write(f.Name);
                sw.Write(" = ");
                sw.Write(SUtilBD.Param(f.Name));
            }
            sw.Write(" where ");
            Primero = true;
            foreach (CFieldM f in this.lFieldPk)
            {
                sw.WriteComma(ref Primero);
                sw.Write(f.Name);
                sw.Write(" = ");
                sw.Write(SUtilBD.Param(f.Name));
            }
        }
Exemplo n.º 9
0
        internal void GeneraSql(CSourceWriter sw)
        {
            bool primero = true;

            //CONSTRAINT AK_TransactionID UNIQUE(TransactionID)
            sw.WriteLn(",constraint " + this.Nombre + " unique (");
            sw.AddTab();
            foreach (CFieldM f in this.LFields)
            {
                sw.WriteComma(ref primero);
                sw.WriteLn("" + f.Name);
            }
            sw.DelTab();
            sw.WriteLn(")");
        }
Exemplo n.º 10
0
 public void GeneraSql(CSourceWriter sw, ref bool primero)
 {
     sw.WriteComma(ref primero);
     sw.Write(this.Name);
     sw.Write(" ");
     sw.Write(this.CadenaTDSqlServer);
     if ((this.Td == SqlDbType.VarChar) || (this.Td == SqlDbType.VarBinary))
     {
         sw.Write("(");
         sw.Write(this.Lenght.ToString());
         sw.Write(")");
     }
     if (this.IsIdentity)
     {
         sw.Write(" identity ");
     }
     if (!this.IsNullable)
     {
         sw.Write(" not null ");
     }
     sw.EndLine();
 }