Base solution for your next web application
Ends in:
01 DAYS
01 HRS
01 MIN
01 SEC

Activities of "vnpedrofilipe"

create one class like this.... include all table from your database

public class PRWEBSistemaBaseTesteDB
    {
        private readonly PRWEBDbContext _context;
        private readonly string _connectionString;

        public PRWEBSistemaBaseTesteDB(PRWEBDbContext context)
        {
            _connectionString = "Data Source=(localdb)\\MSSQLLocalDB;Initial Catalog=PRWEB2;Integrated Security=True;Connect Timeout=30;Encrypt=False;TrustServerCertificate=True;ApplicationIntent=ReadWrite;MultiSubnetFailover=False;";
            //Resolve<IAbpStartupConfiguration>().DefaultNameOrConnectionString = _connectionString;
           

            _context = context;
        }

        public void Build()
        {
            using (SqlConnection con = new SqlConnection(_connectionString))
            {
                //
                // Open the SqlConnection.
                //
                con.Open();
                //
                // The following code uses an SqlCommand based on the SqlConnection.
                //
                using (SqlCommand command = new SqlCommand("SELECT Id, Nome, TenantId, Data FROM Feriados", con))
                using (SqlDataReader reader = command.ExecuteReader())
                {
                    while (reader.Read())
                    {
                        _context.Feriado.Add(
                            new Feriado
                            {
                                Id= reader.GetInt64(0),
                                Nome = reader.GetString(1),
                                TenantId = reader.GetInt32(2),
                                Data = reader.GetDateTime(3)
                            });
                    }
                }
            }
        }
    }

and in testBase, change

//Seed initial data for host
            AbpSession.TenantId = null;
            UsingDbContext(context =>
            {
                // database fake
                //new PRWEBSistemaBaseTeste(context).Build();
                
                // database 
                new PRWEBSistemaBaseTesteDB(context).Build();

                new InitialHostDbBuilder(context).Create();
                new DefaultTenantCreator(context).Create();
                
            });
Showing 1 to 1 of 1 entries