Ejemplo n.º 1
0
 public static void Initialize(IServiceProvider serviceProvider)
 {
     using (var context = new Test2Context(
                serviceProvider.GetRequiredService <
                    DbContextOptions <Test2Context> >()))
     {
         // Look for any movies.
         if (context.Users.Any())
         {
             return;   // DB has been seeded
         }
         context.Users.AddRange(
             new CreateUser {
             NomeR = "raimundo",
             NomeU = "n sei oq e isso",
             Email = "galã[email protected]",
             senha = "NiguemNuncaVaiAcertarIsso"
         },
             new CreateUser {
             NomeR = "maria",
             NomeU = "a estrela",
             Email = "*****@*****.**",
             senha = "senha"
         },
             new CreateUser {
             NomeR = "tiago",
             NomeU = "o matador de porco",
             Email = "*****@*****.**",
             senha = "porco"
         }
             );
         context.SaveChanges();
     }
 }
Ejemplo n.º 2
0
        protected override void Add(TestContext ctx, Parent parent, int count)
        {
            var childrenAdded = new List <Child>(count);

            for (var i = 0; i < count; i++)
            {
                var child = new Child
                {
                    Name = Guid.NewGuid().ToString("N")
                };
                childrenAdded.Add(child);

                ctx.ChildSet.Add(child);
            }
            Timer.CheckPoint($"Added {count}");

            ctx.SaveChanges();
            Timer.CheckPoint("Saved");

            using (var ctx2 = new Test2Context())
            {
                foreach (var child in childrenAdded)
                {
                    ctx2.ParentChildRel2Set.Add(new ParentChildSimpleRel
                    {
                        ParentId = parent.Id,
                        ChildId  = child.Id
                    });
                }
                Timer.CheckPoint($"Added rel {count}");

                ctx2.SaveChanges();
                Timer.CheckPoint("Saved rel");
            }
        }
Ejemplo n.º 3
0
        public IActionResult Index([FromServices] Test1Context context1, [FromServices] Test2Context context2)
        {
            var connection1 = context1.Database.GetDbConnection();
            var connection2 = context2.Database.GetDbConnection();

            Console.WriteLine($"Retrieving data from {connection1.DataSource}/{connection1.Database}");
            Console.WriteLine($"Retrieving data from {connection2.DataSource}/{connection2.Database}");
            return(View((context1.Test1Data.ToList(), context2.Test2Data.ToList())));
        }
Ejemplo n.º 4
0
        public Student GetStudentInfoById(int id)
        {
            Student student = new Student();

            using (Test2Context db = new Test2Context())
            {
                student = db.Students.Where(x => x.StudentId == id).FirstOrDefault();
            }

            return(student);
        }
Ejemplo n.º 5
0
        public List <Student> GetAllStudents()
        {
            List <Student> students = new List <Student>();

            using (Test2Context db = new Test2Context())
            {
                students = db.Students.ToList();
            }

            return(students);
        }
Ejemplo n.º 6
0
        protected override void Add(TestContext ctx, Parent parent, int count)
        {
            var childBatch = new ChildBatch
            {
                DateTime = DateTime.Now,
                Children = new List <Child>()
            };

            ctx.SessionSet.Add(childBatch);
            ctx.SaveChanges();

            for (var i = 0; i < count; i++)
            {
                var child = new Child
                {
                    Name    = Guid.NewGuid().ToString("N"),
                    BatchId = childBatch.Id
                };
                childBatch.Children.Add(child);
            }
            Timer.CheckPoint($"Added {count}");

            ctx.SaveChanges();
            Timer.CheckPoint("Saved");

            using (var ctx2 = new Test2Context())
            {
                var relBatch = new ParentChildBatch
                {
                    DateTime = DateTime.Now,
                    ParentChildSimpleRels = new List <ParentChildSimpleRel>()
                };
                ctx2.ParentChildBatchSet.Add(relBatch);

                foreach (var child in childBatch.Children)
                {
                    //ctx2.ParentChildRel2Set.Add(new ParentChildSimpleRel
                    relBatch.ParentChildSimpleRels.Add(new ParentChildSimpleRel
                    {
                        ParentId = parent.Id,
                        ChildId  = child.Id
                    });
                }
                Timer.CheckPoint($"Added rel {count}");

                ctx2.SaveChanges();
                Timer.CheckPoint("Saved rel");
            }
        }
Ejemplo n.º 7
0
    public Contexts()
    {
        game  = new GameContext();
        test  = new TestContext();
        test2 = new Test2Context();

        var postConstructors = System.Linq.Enumerable.Where(
            GetType().GetMethods(),
            method => System.Attribute.IsDefined(method, typeof(Entitas.CodeGeneration.Attributes.PostConstructorAttribute))
            );

        foreach (var postConstructor in postConstructors)
        {
            postConstructor.Invoke(this, null);
        }
    }
Ejemplo n.º 8
0
 public static System.Collections.Generic.HashSet <Test2Entity> GetEntitiesWithMyNamespaceEntityIndex(this Test2Context context, string value)
 {
     return(((Entitas.EntityIndex <Test2Entity, string>)context.GetEntityIndex(Contexts.MyNamespaceEntityIndex)).GetEntities(value));
 }
Ejemplo n.º 9
0
 public UsersController(Test2Context context)
 {
     _context = context;
 }
Ejemplo n.º 10
0
        static void Main(string[] args)
        {
            Test2Context tc = new Test2Context();

            tc.Clients.ToList <Client>().ForEach(o => Console.WriteLine(o.Name));
        }
Ejemplo n.º 11
0
 public static System.Collections.Generic.HashSet <Test2Entity> GetEntitiesWithMultipleEntityIndicesValue2(this Test2Context context, string value2)
 {
     return(((JCMG.EntitasRedux.EntityIndex <Test2Entity, string>)context.GetEntityIndex(Contexts.MultipleEntityIndicesValue2)).GetEntities(value2));
 }
 public AggregatedCalculator(Test2Context context, ILog logger)
 {
     _logger  = logger;
     _context = context;
 }
Ejemplo n.º 13
0
 public static System.Collections.Generic.OrderedSet <Test2Entity> GetEntitiesWithMyNamespaceMultipleEntityIndicesValue2(this Test2Context context, string value2)
 {
     return(((Entitas.EntityIndex <Test2Entity, string>)context.GetEntityIndex(Contexts.MyNamespaceMultipleEntityIndicesValue2)).GetEntities(value2));
 }
Ejemplo n.º 14
0
 public MoviesController(Test2Context context)
 {
     _context = context;
 }