public void Create(AlunoInteresse ai)
        {
           using (var das = MySession.CreateDataAccessScope(true))
            {
                SqlCommand cmd = CreateCommand();

                cmd.CommandText = "INSERT INTO ALUNOSASSEST(NumAl,Interesse) VALUES(@NumAl,@Interesse)";
                SqlParameter p1 = cmd.CreateParameter();
                SqlParameter p2 = cmd.CreateParameter();
                cmd.Parameters.Add(p1);
                cmd.Parameters.Add(p2);

                p1.ParameterName = "@NumAl";
                p1.SqlDbType = SqlDbType.Int;
                p2.ParameterName = "@Interesse";
                p2.SqlDbType = SqlDbType.VarChar;
                p2.Size = 20;

                p1.Value = ai.Numero;
                p2.Value = ai.Interesse;
                

                cmd.ExecuteNonQuery();

                das.Commit();
            }
        }
Пример #2
0
        static void Main(string[] args)
        {

            
            Aluno a = new Aluno();
            a.Numero = 1111;
            a.Nome = "zeca";

            a.Interesses = new List<AlunoInteresse>();

            var ai = new AlunoInteresse();
            ai.Numero = a.Numero;
            ai.Interesse = "i1";

            a.Interesses.Add(ai);

            ai = new AlunoInteresse();
            ai.Numero = a.Numero;
            ai.Interesse = "i2";
            a.Interesses.Add(ai);

            Aluno a1 = new Aluno();
            a1.Numero = 2222;
            a1.Nome = "rita";

            a1.Interesses = new List<AlunoInteresse>();
            ai = new AlunoInteresse();
            ai.Numero = a1.Numero;
            ai.Interesse="i2";
            a1.Interesses.Add(ai);

            ai = new AlunoInteresse();
            ai.Numero = a1.Numero;
            ai.Interesse="i3";
            a1.Interesses.Add(ai);

            Session s = new Session();
            using (var das = s.CreateDataAccessScope(true))
            {
                IDAOAluno dao = s.CreateDAOAluno();
                dao.Create(a);  
                dao.Create(a1);
                das.Commit();
            }
        }
 public void Delete(AlunoInteresse ai)
 {
     throw new NotImplementedException("Oparação CRUD Ainda não implementada");
 }